如何在自己的应用中使用第三方TvProvider对象? [英] How to use 3rd party TvProvider objects in own app?

查看:96
本文介绍了如何在自己的应用中使用第三方TvProvider对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有一个示例应用,它注册了一个频道对于Android TV,因此,这些频道会在主屏幕上显示,操作系统.

Here we have a sample app, what registers a channel for Android TV, so these channels are provided on the home screen by the operating system.

假设像Netflix,Prime等内容提供商为每个频道提供一个频道,我如何在我的应用程序中显示这些频道?

Assuming that content providers like Netflix, Prime etc. provide each a channel, how can I display these channels in my app?

推荐答案

这些 TvProvider 只能由Android系统访问.创建频道时,您需要在系统中为该频道注册一个提供程序-这实际上就是 TvProvider 的目的.您几乎无法以适当的方式在自己的应用程序中显示您的频道-

Those TvProviders are accessible by the Android system only. When you creating a channel, you need to register a provider for that channel in the system - that is what TvProviders are for essentially. You hardly can display your channel in your own app in a proper way - there is no default channel UI provided by a leanback library - so that you have to create a UI for that yourself or hack around in the leanback components.

您只能使用您创建的频道.您可以创建,更新和管理对它们的访问权限.您在频道创建过程中提供的所有UI内容和内容利用率,都可以处理Android TV系统.

You can work only with the channels you created. You can create, update, and manage access to them - that is all. All the UI stuff and utilization of content, you have provided on channel creation, handles the Android TV system.

您的应用程序中无法访问其他供应商 TvProvider 和渠道,我想永远也不会.

There is no access to other vendors TvProviders and channels from within your app, and I guess there will never be.

以下是查询TvProvider中所有可用频道的方法

Here is how to query all channels available in your TvProvider

private val CHANNELS_MAP_PROJECTION = arrayOf(
    TvContractCompat.Channels._ID,
    TvContractCompat.Channels.COLUMN_INTERNAL_PROVIDER_ID,
    TvContractCompat.Channels.COLUMN_BROWSABLE
)

context.contentResolver.query(
    TvContractCompat.Channels.CONTENT_URI,CHANNELS_MAP_PROJECTION, 
    null, null, null
)        

Here is a neat example from googlecodelabs of how to properly use TvProvider calls.

Here is an example from the same app of how to add your channels to the TvProvider.

此处是Android TV与电视提供商和一般href ="https://source.android.com/devices/tv#permissions" rel ="nofollow noreferrer">限制和可能性描述

Here is the whole flow of how Android Tv works with Tv Providers and general limitations and possibilities descriptions

因此您根本无法做到.只有具有 signature / signatureOrSystem protectionLevel的应用程序才能使用它.唯一使用此类protectionLevel的应用是供应商使用与AOSP本身相同的密钥签名和/或将它们放置在特殊文件夹中的应用-只有设备供应商可以这样做(或您可以,但只能在有根设备上).对于普通的消费类应用程序,您想要的是不可能的.

Thus you are no able to do it at all. Only apps with signature /signatureOrSystem protectionLevel will be able to use it. The only apps that use such protectionLevel are the apps vendors signs with the same key as an AOSP itself and/or placed them in a special folder - only vendors of devices can do it(or you, but only on rooted devices). What you want is impossible for the general consumer app.

这篇关于如何在自己的应用中使用第三方TvProvider对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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