Im creating an application for Google TV. I am trying to create a custom toast overlay over the top of the broadcast.
I have created the custom toast as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_layout_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000" />
</LinearLayout>
and implemented it in the view of the googleTV app:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.main,
(ViewGroup) findViewById(R.id.custom_toast_layout_id));
// Toast...
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
My question is how do i make this app show the normal broadcast information in the app so that I can trigger this overlay during viewing?
Any help greatly appreciated.
Here are some ways of doing this:
You can create an app the user has to explicitly launch every time before they want to see this kind of toast on their live broadcast. The app will have a transparent activity and then display the toast or just a view with the information. Your activity will block all other interactions with the broadcast like changing channels.
Invoke the toast or transparent activity from a service. Look at this open sourced app: https://github.com/entertailion/Overlay-for-GTV
Instead of the toast or transparent view, you can also use a system alert window which is supported by Android to overlay a view on top of any other activity. You need "android.permission.SYSTEM_ALERT_WINDOW" in your manifest and you need to set the window type to "WindowManager.LayoutParams.TYPE_SYSTEM_ALERT".