没有为android.media.tv.action.INITIALIZE_PROGRAMS发送BroadcastReceiver通知

问题描述 投票:0回答:1

不接收应用程序安装在电视上后应发送到应用程序的广播。

我在Manifest.xml中声明了BR:

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

我也宣布:

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

RunOnInstallReceiver类非常简单:

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

我试过nVidia Shield和Mi Box 3 - 没有成功。谁有类似的问题?

android broadcastreceiver android-tv
1个回答
1
投票

你是在加载应用程序吗? INITIALIZE_PROGRAMS仅在通过商店安装应用程序时发送。

当侧面加载(从adb或android studio安装)时,您可以通过以下方式触发intent:

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

答案来自Android开发者指南中的子弹#5,用于在主屏幕上创建频道:https://developer.android.com/training/tv/discovery/recommendations-channel#creating_a_channel

© www.soinside.com 2019 - 2024. All rights reserved.