开发者

Android Error Cant Use FLAG_RECEIVER_BOOT_UPGRADE here

开发者 https://www.devze.com 2023-02-20 09:43 出处:网络
I am trying to start AppB from AppA.On activity of AppB I issue: Intent i = new Intent(); i.setAction(\"START_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.sendB开发者_如何学Pythonroadcast(i)

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

as follows:

 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

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.


Do not use any FLAG_ACTIVITY_ constant with sendBroadcast().


When populating your Intent, do:

intent.setFlags(0);


I ran into this and found out that this is a bug in android. At some point in history this two flags - FLAG_ACTIVITY_NEW_TASK and FLAG_RECEIVER_BOOT_UPGRADE - get the same numeric value because some android developer changed one of their values without checking that it is already taken by another flag. The latest version (4.4) seems to have it fixed already.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号