Issue
I'm developing an Android TV app, and I'm setting up a broadcast receiver to run a work class when the user installs the app. Following the Google documentation, topic number 6, it shows how to add a receiver in the manifest file with the action "android.media.tv.action.INITIALIZE_PROGRAMS". I did that, and also created a simple broadcast receiver class as showed bellow:
class TvLauncherReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Log.d("print", "onReceive ${intent.action}")
}
As described in the documentation, I have to run the following adb command to trigger the broadcast action, as the app was not installed from the play store:
adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n \
your.package.name/.YourReceiverName
I have done all that, the terminal shows me that the Broadcast was completed, but nothing happens. Added a breakpoint and onReceive is not even been called.
Am I missing something there?
Thank you!
Solution
I found out that everything was setup fine. The problem is: The project that I'm working on has a applicationId suffix set in the build.gradle file. Therefore, the correct adb command should be:
adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n \
your.package.name.applicationIdSuffix/.YourReceiverName
If you find yourself with this same issue, make sure to check your build.gradle file for an applicationIdSuffix variable.
Answered By - Gustavopeq
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.