0

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.

Community
  • 1
  • 1
Droidme
  • 1,223
  • 6
  • 25
  • 45

2 Answers2

2

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>
Adnan Mulla
  • 2,872
  • 3
  • 25
  • 35
  • thank u for the answer. Can u tell me what this line means? broadcastIntent .setAction(GeofenceUtils.ACTION_GEOFENCE_TRANSITION) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_ID, geofenceIds) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_TRANSITION_TYPE, transitionType); LocalBroadcastManager.getInstance(MyApplication.getContext()) .sendBroadcast(broadcastIntent); in the receiver class. This line confuses me – Droidme Dec 28 '13 at 09:23
1

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);
Shayan Pourvatan
  • 11,898
  • 4
  • 42
  • 63