Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Tv: get list of channels

I've installed the androidtv-sample-inputs so I can fake some Tv inputs and have some channels and I wanted to get information about that channels, however, when I query to get that information I get an empty cursors.

What i've tried so far is:

TvInputManager tv = (TvInputManager)getApplicationContext().getSystemService(Context.TV_INPUT_SERVICE);

    List<TvInputInfo> list = tv.getTvInputList();

    String[] projection =  {
            TvContract.Channels._ID,
            TvContract.Channels.COLUMN_DISPLAY_NUMBER
    };

    ContentResolver cr = getContentResolver();

    Iterator<TvInputInfo> it = list.iterator();
    while(it.hasNext()) {
        TvInputInfo aux = it.next();
        Uri uri = TvContract.buildChannelsUriForInput(aux.getId());

        Log.d("TAG", uri.toString());
        Log.d("TAG", aux.toString());

        Cursor cur = cr.query(uri, projection, null, null ,null);
        Log.d("TAG", cur.toString());

        if(cur.moveToFirst()) {
            Log.d("TAG", "not empty cursors");
        }

    }

I have already added the uses-permission and I've checked that the tv input are not pass-through.

<uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" />
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
<uses-permission android:name="com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA"/>
like image 260
user1139368 Avatar asked Feb 23 '15 17:02

user1139368


People also ask

How do I watch channels on my Android TV?

Watch channels from an app or a TV tuner Most Android TVs come with a TV app where you can watchall your shows, sports, and news. To learn how to use the TV app on your TV, contact your device manufacturer. If your device does not come with a TV app, you can use the Live Channels app.

How to watch live TV on Google TV?

As Google TV doesn’t have channels of its own, you need to have a YouTube TV subscription to watch Live TV channels on it. You can find the list of channels on YouTube TV here.

How do I access the TV provider's data on Android TV?

The Android TV home screen uses Android's TvProvider APIs to manage the channels and programs that your app creates. To access the provider's data, add the following permission to your app's manifest: Note: The READ_EPG_DATA permission was deprecated in Android M (API 23) and is no longer needed.

How do I set up live channels on my TV?

Choose which channels you want to show up in your program guide. To return to your Live Channels stream, press the Backbutton. Watch your channels You can change channels with your remote. You can also choose a channel from your Program guide. On your Android TV, go to the Home screen. Scroll down to the "Apps" row. Select the Live Channelsapp.


1 Answers

What kind of permission are you using ?

If your application isn't signatureOrSystem, you can only access your own channels and programs from queries to the TV provider. All the queries you're doing are filtered on your package name.

I guess that the information you can retrieve from a channel are restricted to what is accessible from TvInputInfo.

like image 179
ph0b Avatar answered Sep 23 '22 00:09

ph0b