[英]getContentResolver().query(TvContract.Channel.CONTENT_URI, projection, null, null, null) returns empty cursor
I am trying to get all the available channels in TvProvider database (tv.db), with help of the below code.我正在尝试借助以下代码获取 TvProvider 数据库(tv.db)中的所有可用频道。 But the cursor is returning as empty.但是 cursor 返回为空。
val tvInputManager = getSystemService(TvInputManager::class.java)
tvInputManager.registerCallback(tvInputCallback, handler)
if (tvInputManager.tvInputList != null && tvInputManager.tvInputList.size > 0) {
for (input in tvInputManager.tvInputList) {
if (input != null && !input.isPassthroughInput) {
val projection = arrayOf(
TvContract.Channels._ID,
TvContract.Channels.COLUMN_DISPLAY_NUMBER
)
var tvInputInfo = tvInputManager.getTvInputInfo(input.id)
var uri = TvContractCompat.buildChannelsUriForInput(tvInputInfo?.id)
val cursor = contentResolver.query(TvContract.Channels.CONTENT_URI, projection, null, null, null)
Log.d("CHANNELS_DATA", "${TvContract.Channels.CONTENT_URI}")
cursor?.moveToFirst()
Log.d("CHANNELS_DATA", "${cursor?.count} CHANNELS FOUND")
}
}
}
Below are the permissions added in the Android Manifest file下面是Android Manifest文件中添加的权限
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_TV_LISTINGS" />
<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" />
<uses-permission android:name="com.android.providers.tv.permission.ACCESS_WATCHED_PROGRAMS" />
You will get only own channels (channels added by your Tv Input Service).您将只获得自己的频道(由您的电视输入服务添加的频道)。 To be able to list all entries your app should have special ( signatureOrSystem
) permission: ACCESS_ALL_EPG_DATA
.为了能够列出所有条目,您的应用程序应该具有特殊 ( signatureOrSystem
) 权限: ACCESS_ALL_EPG_DATA
。 Please check docs: https://source.android.com/devices/tv#permissions_and_access_control请查看文档: https://source.android.com/devices/tv#permissions_and_access_control
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.