Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Error Cant Use FLAG_RECEIVER_BOOT_UPGRADE here

Tags:

android

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)

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.

like image 908
Androider Avatar asked Mar 25 '11 22:03

Androider


2 Answers

Do not use any FLAG_ACTIVITY_ constant with sendBroadcast().

like image 195
CommonsWare Avatar answered Sep 28 '22 10:09

CommonsWare


When populating your Intent, do:

intent.setFlags(0);
like image 25
David S Alderson Avatar answered Sep 28 '22 10:09

David S Alderson