未为android.media.tv.action.INITIALIZE\u程序发送BroadcastReceiver通知
未收到应在应用程序安装到电视上后立即发送到应用程序的广播 我在Manifest.xml中声明了BR:未为android.media.tv.action.INITIALIZE\u程序发送BroadcastReceiver通知,android,broadcastreceiver,android-tv,Android,Broadcastreceiver,Android Tv,未收到应在应用程序安装到电视上后立即发送到应用程序的广播 我在Manifest.xml中声明了BR: <receiver android:name=".RunOnInstallReceiver" android:exported="true"> <intent-filter> <action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" /> <
<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>
我尝试了英伟达盾和米盒3-没有成功。有人有类似的问题吗?您是否在侧面加载应用程序?只有通过应用商店安装应用程序时,才会发送INITIALIZE_程序 侧面加载(从adb或android studio安装)时,您可以通过以下方式触发意图:
adb shell am广播-a android.media.tv.action.INITIALIZE_PROGRAMS-n com.your.app.package/.YourReceiver
答案来自《Android开发者指南》中关于在主屏幕上创建频道的项目符号5:在我的情况下,如果您使用
产品风味
,您应该通过以下方式触发:
adb shell am广播-a android.media.tv.action.INITIALIZE_节目-n X/Y
X
是您的应用程序ID。
Y
是项目中广播接收文件的链接
示例:使用构建变体构建应用程序,触发器为:
adb shell am广播-a android.media.tv.action.INITIALIZE_程序-n com.google.android.staging/com.google.android.tvhomescreenschannels.RunOnInstallReceiver
以下是应用程序ID:
以下是安装接收器的路径:
我和你有同样的问题,甚至我使用了adb shell am broadcast-a android.media.tv.action.INITIALIZE\u PROGRAMS-n com.your.app.package/.YourReceiver。但它不起作用。
<uses-feature
android:name="android.software.leanback"
android:required="true" />
public class RunOnInstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.v("RAMPS", "Broadcast received");
}
}