Ramps
Ramps

Reputation: 5298

BroadcastReceiver notification not sent for android.media.tv.action.INITIALIZE_PROGRAMS

Broadcast which should be sent to the application just after app is installed on TV is not received.

I declared BR in Manifest.xml:

<receiver
   android:name=".RunOnInstallReceiver"
   android:exported="true">
   <intent-filter>
     <action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" />
     <category android:name="android.intent.category.DEFAULT" />
   </intent-filter>
</receiver>

I declared also:

<uses-feature
    android:name="android.software.leanback"
    android:required="true" />

RunOnInstallReceiver class is very simple:

public class RunOnInstallReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
     Log.v("RAMPS", "Broadcast received");
  }
}

I tried with nVidia Shield and Mi Box 3 - no success. Anyone had similar problem?

Upvotes: 1

Views: 1478

Answers (2)

Duong.Nguyen
Duong.Nguyen

Reputation: 413

In my case, if you use product flavor you should trigger by:

adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n X/Y

X is your applicationID. Y is the link of your broadcast received file in your project.

Example: You build your application with Build variants staging and trigger is:

adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n com.google.android.staging/com.google.android.tvhomescreenchannels.RunOnInstallReceiver

Here is ApplicationId: enter image description here

Here is path RunOnInstallReceiver: enter image description here

Upvotes: 1

Bryan
Bryan

Reputation: 367

Are you side loading the application? INITIALIZE_PROGRAMS is only sent when the application is installed via the store.

When side loading (installing from adb or android studio), you can trigger the intent with:

adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n com.your.app.package/.YourReceiver

Answer is from bullet #5 in Android developer guide for creating a channel on the home screen: https://developer.android.com/training/tv/discovery/recommendations-channel#creating_a_channel

Upvotes: 4

Related Questions