I’m using Android and Google Maps at API level 10, and I get latitude and longitude by telnet.
public void onLocationChanged(Location location) {
lat = location.getLatitude();
lng = location.getLongitude();
//...
}
But the user should move first. Is there any other solution?
An alternative to onLocationChanged(Location location) is using a location manager and broadcast receiver to get the user’s location information. Refer to the docs to read all about the Location Manager class. With the location manager class you will be able to set an interval in which you want to probe the user’s location even when they haven’t moved. You will have:
In the LocationReceiver class (Broadcast Receiver) you will have an onRecieve() method in which you can use:
You can use that location object for many things, refer to the Android Location docs.