Monday, 15 July 2013

android - Resume activity from broadcast receiver -



android - Resume activity from broadcast receiver -

i'm trying resume activity within broadcast receiver's onreceive() method follows:

intent = new intent(context, timerset.class); i.setflags(intent.flag_activity_reorder_to_front | intent.flag_activity_new_task); context.startactivity(i);

however activity (timerset.class) recreated instead of resumed. recommended solution found problem utilize flag_activity_reorder_to_front i'm using it.

also, using intent.flag_activity_new_task doesn't fit utilize case next exception when not provide it:

android:util.androidruntimeexception: calling startactivity() outside of activity context requires flag_activity_new_task flag. want?

i not sure whether problem or not, have situation got notification , want start app without starting new instance (if it's running) figured out these work. flag_activity_new_task not start new instant if activity has been running. however, add together existing stack. therefore, can flag_activity_clear_top, bring user home screen not previous state.

intent.setflags(intent.flag_activity_new_task | intent.flag_activity_clear_top);

android android-activity broadcastreceiver

No comments:

Post a Comment