0

I'm trying to get googleMaps work in my BroadcastReceiver --> OnReceive ( not in MainActivity) But I cant because i cant use getSupportFragmentManager(). So it turns out that im getting NullPointerEcxeption because of GoogleMap Being null...

Im stuck on that and i dont know how to continue ...

Followed by my previous questions: my app doesnt work ( infinite loop } And https://stackoverflow.com/questions/23578571/sending-googlemap-intent-to-broadcastreceiver You can see the code's in those links..

I would be glad to hear any of your idea's ! Thanks.

Community
  • 1
  • 1
mynavy
  • 81
  • 2
  • 9

1 Answers1

1

Actually BroadcastReceiver is not the right place to show map or any view.

So what should be the actual flow?

1) Create MapActivty.java and implement whatever you did in BoradcastReceiver.

2) Now what you will do in Your BroadcastReceiver?

call the MapActivity from onReceive() method

E.g

public void onReceive(Context context, Intent intent) {
      Intent mapintent = new Intent(context, MapActivity.class);
      context.startActivity(mapintent);
}
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
  • Sounds interesting Thanks. But i dont want to show the map I just want to get googlemap Coordinates of the other android device ,is it possible to just get current location coordinates with that method without showing the user any map ? Thanks. – mynavy May 10 '14 at 10:18
  • what is you exact need? What do you mean by googlemap coordinate of the other android device? – Biraj Zalavadia May 10 '14 at 10:24
  • Basically my app sends a set of coordinates to another android device and when he is getting to those coordinates his device will send me a message.. So i need on his side to keep getting corrdinates of his location untill hes on the same coordinates that i sent him. – mynavy May 10 '14 at 10:28
  • how you transmitting co-ordinates to other android device – Biraj Zalavadia May 10 '14 at 10:31
  • What I understand is that you want to compare the location that you got in sms with your current location if the location matches you want to replay the message right? – Biraj Zalavadia May 10 '14 at 10:35
  • what you can do is Implement Location service to monitor your location and keep storing your location to sharedpreference and in on receive method read your location from sharedpreference and compare with other device location that you got in intentdata – Biraj Zalavadia May 10 '14 at 10:42
  • hmm ok location service is like : Location lm = googleMap.getMyLocation() ?? and with sharedpreference i never worked with.. can you give me an example ? Thanks !! – mynavy May 10 '14 at 10:46