Error using C ++ for Android. Use FLAG_RECEIVER_BOOT_UPGRADE here.

I am trying to run AppB from AppA. About the activities of AppB, I issue:

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

Inside the AppB I have a broadcast receiver that listens for the START_APPB intent filter.

in the following way:

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

Note. In each case, the context is the context of the actions of the corresponding application.

This causes an activity manager failure error:

 IllegalArgumentException: Can't use FLAG_RECEIVER_BOOT_UPGRADE here 

I have never seen this error before. When I sent the same message from the first activity of the application, it starts without errors, but somehow not on the third page, using the context of the third page.

+4
source share
3 answers

Do not use the FLAG_ACTIVITY_ constant with sendBroadcast() .

+9
source

When filling out your intention, do:

 intent.setFlags(0); 
+4
source

I came across this and found out that this is a bug in android. At some point in history, these two flags - FLAG_ACTIVITY_NEW_TASK and FLAG_RECEIVER_BOOT_UPGRADE - get the same numerical value because some Android developers changed one of their values ​​without checking that it was already accepted by the other flag. The latest version (4.4) seems to have already been fixed.

+1
source

Source: https://habr.com/ru/post/1345290/


All Articles