1. Are you ready for the Galaxy S20? Here is everything we know so far!

Send broadcast to activity that is not running

Discussion in 'Android Development' started by NuffsaidM8, Jan 19, 2016.

  1. NuffsaidM8

    NuffsaidM8 Newbie
    Thread Starter

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...