Android TV: application notifications on O+

Igor Steblii
3 min readAug 5, 2019

--

Although there are many articles that cover notifications in Android O and further versions, there is almost no information about notifications in Android TV platform. This topic is much more advanced and without the support of Google, it is almost impossible to resolve it.

Since I went all the path from the investigation on my own, comparing Google native application and receiving support from Google I want to share my experience to make this clear for other developers.

Android TV limitations

In case if you will follow any available tutorial to publish notification via notification channel on the Android TV — it will not work. In the logcat you will see the next message:

TVNotifService: skipped notification StatusBarNotification(pkg=com.my.application user=UserHandle{0} id=2 tag=MyChannel key=0|com.my.application|2|MyChannel|1000: Notification(channel=MyChannel pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x100 color=0xff048f80 category=sys vis=PUBLIC)) userId: 0

Notification is ignored, this seems totally unexpected to anybody who was working with the notification channels on Android phones, but due to Android TV specific UI/UX — notifications are allowed only for the system white-listed application.

AOSP Dependency

  • You will need to have access to the AOSP sources to white-list your application and configure proper access to the system API.

Setup Wizard

We start from the setup wizard, under setup wizard I mean an application that has registered a receiver for the:

<action android:name="com.google.android.tvsetup.action.PARTNER_CUSTOMIZATION" />

This is an entry point for our customization. BTW: receiver itself could be empty but must be registered.

Configurations

Android provides specific broadcast for Android TV platform that is sent on the first boot of the firmware, we should register it in our setup wizard application:

<receiver android:name=".configuration.PartnerConfigurationReceiver">
<intent-filter>
<action android:name="com.google.android.tvlauncher.action.PARTNER_CONFIGURATION" />
</intent-filter>
</receiver>

It is broadcasted only on the first boot of the system and notifies an application that we are reading system configurations. It could be used to load system/region specific customization from the external storage, server etc. Even if configuration file is saved in local storage this receiver should be registered.

Loaded configurations are saved in Android TV specific content provider, which we need to register as well:

<provider
android:name=".configuration.ConfigurationProvider"
android:authorities="tvlauncher.config"
android:enabled="true"
android:exported="true" />

After the first boot, this content provider will be read-only.

Configurations file

in our example will be stored locally in the Wizard Setup app:

res/raw/configuration.xml

In the configuration file we will be white-listing packages that can have access to the notification:

<configuration>
<partner-package-notification-whitelist>
<package-name>com.my.application</package-name>
</partner-package-notification-whitelist>
</configuration>

Content provider read the configuration file and write it to the storage:

Last thing — posting of the notification. It is almost the same as on Android phone using Notification Channels:

The only platform-specific changes that are required to post notification:

.extend(new Notification.TvExtender().setSuppressShowOverApps(true))

This extension is a system private API and available only for the embedded application. To make private API available to the application on the AOSP we need to add one line to the Android.mk:

LOCAL_PRIVATE_PLATFORM_APIS := true

Conclusion

Google has its reasons to disable notifications as they are on the Android TV platform, therefore don’t misuse acquired knowledge.

Good luck!

--

--

Responses (2)