Search code examples
androidandroid-layoutandroid-intentgoogle-maps-api-3mapactivity

updating google maps marker from a broadcast sms receiver


I am a newbie to android and java. I am trying to make an application to perform following task.

  • receive incoming sms (which will have latitude and longitude information)
  • show them on map with markers So every time an sms comes map should get a new marker.

currently I have a map where I can show a point and I have implemented a broadcast receiver to get lattitude and longitude form SMS.

But I am unsure how to update the map from broadcast receiver on receiving a new sms.

Any help or tips will be useful.

Thank you


Solution

  • It sounds like you are looking for detail on how to communicate between your Activity and the BroadcastReceiver? One approach (there are many different approaches) is to have your map Activity register a temporary BroadcastReceiver that is setup to only listen to private broadcasts from your app, and then have your SMS broadcast receiver generate a new broadcast with the latitude/longitude from the SMS. In your map Activity your receiver will add a new point to the map every time it receives a new private broadcast.