i have a LocationService class (extends Service implements LocationListener) that works constantly updates a global variable whenever a new location is obtained via the onLocationChanged method.
in the onCreate method of my launcher activity, i start this service. the next thing i do is to call a web service that takes in the latitude and longitude from the global variable.
this gives me a NullPointerException on the location global variable and i am assuming its because the service is running on a separate thread and have not obtained a location yet.
Question: how do i make it such that i will only call the web service only when a location has been obtained from the service class?
thanks so much. 🙂
YourServiceinforms every registeredLocationOperatorwhen location is changed.LocationOperatoris a simple interface, declaresoperate(Location)method.Start and connect to this service from your main activity
Then you can reach this service over
MainActivityand register forLocation