11

I define BroadcastReceiver in an application manifest and the receiver receives events in onReceive as expected. However I do not create the receiver class so I can't pass any information about my activity which the receiver is supposed to control. Context parameter gives me only application context and no any activity reference. So what is right way to make communication between application activities and broadcast receiver?

Don Cesar D'Bazar
  • 321
  • 1
  • 2
  • 9

2 Answers2

1

The answer is a little twisted but I found it here as well Inform Activity from a BroadcastReceiver ONLY if it is in the foreground It seems working. Please close the question then.

Community
  • 1
  • 1
Don Cesar D'Bazar
  • 321
  • 1
  • 2
  • 9
-2

You can communicate broadcast to activity from this:-

   Intent intent=new Intent(context,YourActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
           context.startActivity(i);
Deepanker Chaudhary
  • 1,694
  • 3
  • 15
  • 35