Android的错误不能使用FLAG_RECEIVER_BOOT_UPGRADE这里错误、Android、FLAG_RECEIVER_BOOT_UPGRADE

2023-09-06 17:30:24 作者:你的下一个ヽ未必比我好

我想从APPA开始APPB。在APPB活动我发出:

I am trying to start AppB from AppA. On activity of AppB I issue:

Intent i = new Intent();
             i.setAction("START_APPB");
             i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                             context.sendBroadcast(i)

里面APPB我有一个广播接收器正在监听START_APPB意图过滤器。

Inside AppB I have a broadcast receiver that is listening on START_APPB intent filter.

如下:

 Intent i = new Intent();
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setAction("SHOW_APPBPAGE");
        context.startActivity(i);

请注意在每个案件方面是各个应用程序的活动环境。

Note in each case context is the activities context of the respective app.

这导致从活动管理器崩溃错误:

This causes a crash error from activity manager:

IllegalArgumentException:  Can't use FLAG_RECEIVER_BOOT_UPGRADE here

我还从来没见过这样的错误。当我发出同样的消息从应用程序的第一个活动运行没有错误,但不知何故没有在第3页,使用第三页的内容。

I have never seen this error before. When i have sent same message from first activity of App it runs without error, but somehow not on 3rd page , using context of third page.

推荐答案

不要使用任何 FLAG_ACTIVITY _ 常量 sendBroadcast()