Droidme
Droidme

Reputation: 1252

Sending and receiving broadcast from the same receiver

Hello I was trying to implement a custom Broadcast receiver for my Geofence app. I just went through the solution given here But I found that he is sending the broadcast from the receiver class which receives the same broadcast. can someone please tell me how this works. I have not worked much on custom broadcast.

Upvotes: 0

Views: 724

Answers (2)

Adnan Mulla
Adnan Mulla

Reputation: 2866

He is sending the broadcast from one class and receiving it in another receiver. The line below is where he sends out the broadcast.

              Intent intent = new Intent("com.aol.android.geofence.ACTION_RECEIVE_GEOFENCE");

Here is his manifest where he registers a receiver for that broadcast

   <receiver android:name="com.aol.android.geofence.GeofenceReceiver"
    android:exported="false">
    <intent-filter >
        <action android:name="com.aol.android.geofence.ACTION_RECEIVE_GEOFENCE"/>
    </intent-filter>
</receiver>

Upvotes: 2

Shayan Pourvatan
Shayan Pourvatan

Reputation: 11948

you can send one Broadcast in another one with following code:

ntent local = new Intent();
local.setAction("BroadCastPath"); // like android.receiver.MyReceiver 
context.sendBroadcast(local);

Upvotes: 1

Related Questions