2

I am trying to follow along here. I have just starting learning to work with channels on GoogleTV.

https://developers.google.com/tv/android/docs/gtv_channelchanging

This doc says...

*Any Google TV Android application can change the TV channel programmatically. To do this, the app calls startActivity() with an Android Intent object set to the action ACTION_VIEW. Any Google TV Android application can change the TV channel programmatically...Notice that this Intent does not specify a component name, By default, this Intent is handled by the Live TV player, which is part of the Google TV platform. If you want, you can declare an intent filter for this Intent in your Google TV application's manifest (AndroidManifest.xml). You can then offer your application as an alternative for handling the Intent.*

I am trying to do this. I want to intercept the channel change when the user types the channel (a number) into their gtv remote, do something with that channel number data, and then let the Live Player change the channel. I was hoping that an activity that was set with an intent-filter action of ACTION_VIEW would catch the channel change when the user types into the remote.

<activity android:name="com.xxx.ActionViewActivity">
   <intent-filter>
      <action android:name="android.intent.action.ACTION_VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
   </intent-filter>
</activity>

Then, the ActionViewActivity.java:

public class ActionViewActivity extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Intent intent = getIntent();
        Log.i(getClass().getName(), intent.getAction());
    }
}

It never makes it to the onCreate method. What am i missing here?

ZippyFerguson
  • 889
  • 1
  • 7
  • 8

3 Answers3

3

This worked for me:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <data android:scheme="tv" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

No special permissions were required.

However, this only handles the case when the channel changing API is invoked. It does not handle the cases when the user presses the channel up/down buttons or enters a channel number when the TV is active. The Google TV Remote app does not use the channel changing API, it just passes the key codes to Google TV. The Able Remote app does use the channel changing API for its favorite channels feature.

If you add this intent filter to your app, the user will be prompted onscreen whether your app or the TV app should be used to do the action. If the user selects your app, you will get the following intent:

Intent { act=android.intent.action.VIEW dat=tv://channel?deviceId=Logitech01&channelNumber=756 flg=0x13c00000 cmp=com.x.x./.xActivity }

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17
  • I know it's been years, but, is there any way of sinking the channel-up/channel-down events from the remote and preventing the default channel-change action? That way an app could capture those events, make the proper channel-change calls and still know what channel the user landed on. How about with the new AndroidTV Api (for which there doesn't seem to be any documentation) :) – znelson Oct 09 '14 at 13:56
2

You need the scheme (protocol). Try:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <data android:scheme="tv" />
  ...
saxman
  • 1,965
  • 16
  • 17
0

Try: android.intent.action.VIEW

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17
  • I changed the intent filter action to: still, nothing. I am starting to think that there is no way to capture a channel change when the user is changing from the gtv remote nor make a query like, "what channel is the user watching?" I hope I am just missing something. – ZippyFerguson Jan 20 '12 at 14:17
  • Anyone have an example where they do this: _By default, this Intent is handled by the Live TV player, which is part of the Google TV platform. If you want, you can declare an intent filter for this Intent in your Google TV application's manifest (AndroidManifest.xml). You can then offer your application as an alternative for handling the Intent._ – ZippyFerguson Jan 20 '12 at 14:25
  • could this be a permissions issue? do i need a special permission in my manifest that I am missing? – ZippyFerguson Jan 20 '12 at 14:34
  • Try: There definitely isn't an API to determine what channel the user is currently watching. – Leon Nicholls Jan 20 '12 at 17:33