I have Three class
1.MenuActivity
2.LocationUpdateService
3.MultipleMarker
1.MenuActivity
@Override
protected void onStart() {
super.onStart();
bindService(new Intent(this, LocationUpdatesService.class), mServiceConnection,
Context.BIND_AUTO_CREATE);
}
2.LocationUpdateService:(This is Service Class)
private void sendMessageToActivity(Location l, String msg) {
Intent intent = new Intent("GPSLocationUpdates");
// You can also include some extra data.
intent.putExtra("Status", msg);
Bundle b = new Bundle();
b.putParcelable("Location", l);
intent.putExtra("Location", b);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
Toast.makeText(context,"Sending Data to BroadCast Receiver",Toast.LENGTH_LONG).show();
}
3.MultipleMarker(Activity)
LocalBroadcastManager.getInstance(this).registerReceiver(
mMessageReceiver, new IntentFilter("GPSLocationUpdates"));
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Get extra data included in the Intent
String message = intent.getStringExtra("Status");
Bundle b = intent.getBundleExtra("Location");
Log.d("messagesshow","****** "+message);
Location lastKnownLoc = (Location) b.getParcelable("Location");
if (lastKnownLoc != null) {
Log.d("messagesshow","***** "+String.valueOf(lastKnownLoc.getLatitude()));
}
Toast.makeText(context, "Data Receiver called", Toast.LENGTH_SHORT).show();
}
};
My Problem is that : When i open My MenuActivity My Toast Messages printing Sending Data to BroadCast Receiver then onclick of Button I am calling MultipleMarker.class there i am not able to getting the values from service...But when i press back button i redirect to MenuActivity at that time i getting values...
I want to get data from my LocationUpdateservice class into in my MultipleMarker.class activity...