Android电视:获取频道列表

问题描述 投票:7回答:2

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

到目前为止我尝试的是:

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");
        }

    }

我已经添加了使用许可,我已经检查过电视输入没有传递。

<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"/>
android android-tv
2个回答
2
投票

你使用什么样的许可?

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

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


0
投票

除了清单文件中所需的“com.android.providers.tv.xxx”EPG权限之外,您还必须在.apk上签名!否则,您将看到设备上可用的所有TvInput,但没有组成这些tvInput的通道(并且没有任何错误返回;-))。 Android Studio提供此功能('BUILD'菜单条目然后'生成签名APK')请参阅How to sign an android apk file

© www.soinside.com 2019 - 2024. All rights reserved.