Start Activity from BroadcastReceiver only once using locks --Android -


scenario :

when 2 alarms set @ same time, of them should shown.

my problem:

i have broadcastreceiver forwards intent alarmgooffactivity when time. however, need check if alarmgooffactivity running before forwarding intent. 1 of answers saw in so. tried approach.earlier, both alarms fired. now, neither alarm fires now.

code

mybroadcastreceiver.java

 if (alarmgooffactivity.running) {                    blog("alarmactivity running");              } else {                 blog("alarmactivity  not running ");                  //set variable true new broadcasts not entertained                 alarmgooffactivity.running = true;                  intent intent1 = new intent(context, alarmgooffactivity.class);                 intent1.setflags(intent.flag_activity_new_task);                 intent1.putextra(dbhelper.column_id, id);                 string ext = extras.getstring(dbhelper.task_title);                 if (ext != null) {                     intent1.putextra(dbhelper.task_title, ext);                 }                 blog("starting alarm fire");                 context.startactivity(intent1);             } 

alarmgooffactivity.java

public class alarmgooffactivity extends actionbaractivity {  public static boolean running = false; .....   @override public void ondestroy() {     super.ondestroy();       //changing lock false here. new 1 can start      //broadcastreceiver     running = false;     } } 

i expecting first 1 fire. now, neither 1 fires. why not working? because of static variable (some concept missed?) or because of time gap of 10 or less milliseconds between broadcasts. help.

the receiver should handle intent , exit quickly. should not try determine if activity visible or active or whatever.

instead, should have activity handle re-notifications. in particular, find onnewintent useful processing new intents sent receiver. in activity can set flags determine how handle re-notifications versus state activity in.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -