2

On the LG G2 Google TV, any attempt to query the channel listing provider throws this exception: "Invalid URI: content://com.google.android.tv.provider/channel_listing"

This is true with the official channel changing example, and my own code, both of which I've demonstrated to work on the Sony GTV buddy box.

Am I missing something here? Is there some LG sauce I'm not aware of? Or is this plain and simple an LG bug?

2 Answers2

4

UPDATE: change your uri to:

Version 3 of GTV

content://com.google.tv.mediadevicesapp.ChannelListingProvider/channel_listing

Also:

change required permission from com.google.android.tv.permission.READ_CHANNELS to com.google.android.tv.mediadevices.permission.READ_STREAMS

The data you get back will be a little different too:

"channel_uri" changed to "url" "channel_name" changed to "name" "channel_number" changed to "channelNumber" "callsign" changed to "subName"

To support both v2 & v3

int version = 0;
try {
    Class cl = Class.forName("com.google.android.tv.Version");
    version = cl.getField("GTV_SDK_INT").getInt(null); }
catch (Exception ex) {}

String contentUri;

if (version == 0) {
    // We're on old (Pre-V3 GoogleTV)
    contentUri = "content://com.google.android.tv.provider/channel_listing";
} else {
    // We're on V3 or newer.
    contentUri = "content://com.google.tv.mediadevicesapp.ChannelListingProvider/channel_listing";
    // or, if you're using the framework library:
    // Uri contentUri = com.google.android.tv.provider.ChannelListingContract.Channels.CHANNEL_LISTING_URI
}

/*

Column names are:

callsign
channel_name
channel_number
channel_uri
data_source

*/
Krispy
  • 1,098
  • 1
  • 7
  • 11
0

I couldn't get anything to work based on the published code examples from Google. But I stumbled onto this and it now works:

http://pastebin.com/CAKBWpCg

Seems if you have the wrong Uri or column names you'll get a null cursor.

znelson
  • 919
  • 1
  • 10
  • 24