• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Send broadcast to activity that is not running

I have a broadcast receiver that is detecting a boot up of the phone. This part works fine. What I want to do is send a notification to a broadcast receiver in the Main Activity of the app, which is registered in the onCreate method as having an intent filter of "RESET_ALARM". This is what doesn't seem to be working. I tried starting the application with this (found it on stackkoverflow):

Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Intent intent1 = new Intent("RESET_ALARM");
context.sendBroadcast(intent1);

but this does not seem to be working. I know the code is running, but a log statement in the receiver in the MainActivity.class file is not logging to the logcat. What am I doing wrong?
 
Back
Top Bottom