Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

pass broadcast from the Service class to the Map activity.  RSS feed

Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have TrackingService component to track the location of the buses in my city based on Crowdsourcing. In the TrackingService class I have variable `pLong, pLat` to stored the latitude and longitude when they are calaculated in the `onLocatiochChanged()`. The TrackingService is operating in the background, then the data is transmitted to the server. I have an Map Activity to display the location of the buses, the user selected in the MainActivity( as Filter).

The background TrackingService is started in the MainActivity when the app launches.

I am trying to pass the `pLat, pLong` from the `onLocationChanged()` to the `Map` activity when the `onLocationChanged()`is being invoked to display the user's current location beside the bus's locations with the aid of BroadcastReceiver.

I have debugged my code and facing problem that I am getting `0.0` for the values `lat, lng` in the BroadcastReiceiver in the `map` activity also the `bReceiver` is being invoked.

How can I get it to work to retrieve the lat and lng vlaues in the BroadcastReceiver `bReceiver`?

I appreciate any help.

TrackingService class

Map activity


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!