Android 电视:获取频道列表 [英] Android Tv: get list of channels

查看:51
本文介绍了Android 电视:获取频道列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 androidtv-sample-inputs,所以我可以伪造一些电视输入并拥有一些频道,我想获取有关该频道的信息,但是,当我查询以获取该信息时,我得到了一个空光标.

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"/>

推荐答案

您使用的是哪种权限?

如果您的应用程序不是signatureOrSystem,则您只能通过向电视提供商查询来访问您自己的频道和节目.您正在执行的所有查询都会根据您的包名称进行过滤.

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.

我想您可以从频道中检索的信息仅限于可从 TvInputInfo 访问的信息.

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

这篇关于Android 电视:获取频道列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆