Skip to content Skip to sidebar Skip to footer

How To Use 3rd Party Tvprovider Objects In Own App?

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. Assuming that content providers like

Solution 1:

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.

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.

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

Here is how to query all channels available in your TvProvider

privatevalCHANNELS_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.

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

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.

Post a Comment for "How To Use 3rd Party Tvprovider Objects In Own App?"