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?
Asked
Active
Viewed 1.2k times
11
-
y u need activity if u can say that will b helpful ? – Android Killer Jul 16 '13 at 05:38
-
this is the right answer: http://stackoverflow.com/questions/11411395/how-to-get-current-foreground-activity-context-in-android – yshahak Feb 03 '15 at 15:37
2 Answers
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
-
5I do not need to start an activity, I need to communicate with an existing one. – Don Cesar D'Bazar Jul 16 '13 at 06:34