Partner_Customization 接收器是系统广播还是自定义广播?

时间:2021-04-12 07:02:33

标签: broadcastreceiver android-tv

我想在获得 partner_customization 接收器后启动一个应用程序。但我做不到。 我已经写在 AndroidManifest.xml 文件中

<receiver android:name="com.example.splashscreen.CustomizationReceiver"
        >
    <intent-filter>
        <action
            android:name="com.google.android.leanbacklauncher.action.PARTNER_CUSTOMIZATION"
            />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    </receiver>

并创建接收器 CustomizationReceiver

公共类 CustomizationReceiver 扩展 BroadcastReceiver { 私有静态最终字符串 ACTION_PARTNER_CUSTOMIZATION = "com.google.android.leanbacklauncher.action.PARTNER_CUSTOMIZATION";

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.d("CustomizationReceiver","intent" + action);

    if (ACTION_PARTNER_CUSTOMIZATION.equals(action)) {
        Intent myIntent = new Intent(context, MainActivity.class);
        myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(myIntent);
        Log.d("CustomizationReceiver","Received");


    }else{
        Log.d("CustomizationReceiver","Not Received");
    }
}

}

我在这个应用程序中做错了什么吗? 我需要为partner_Customization 接收器创建自定义广播吗?还是会在启动器应用(主屏幕)启动时由系统自动调用?

0 个答案:

没有答案