Reputation: 1697
i m working on one application which has to find the lat and long of the user's location and then display on the map. But when internet is there on the device its working fine. but when i try after disconnected the internet its getting lat and long null.
Queries:
Upvotes: 1
Views: 1040
Reputation: 5242
If you want to display it on the map, use MyLocationOverlay. Its way easier then implementing your own locationListeners. Call enableMyLocation onResume() and disableMyLocation onPause().
You can also subclass MyLocationOverlay to change the icon, do custom stuff on location changes, etc.
Upvotes: 0
Reputation: 11669
The fact is, there are two ways for Android to determine your longitude/latitude.
So, if GPS is deactivated (or unable to catch a signal, due to being indoors or to bad meteorological conditions), and network too, Android is unable to compute your coordinates.
Upvotes: 3
Reputation: 16603
You can determine device location programatically by implementing LocationListener
and
something like this:
LocationManager locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); //"this" implements LocationListener
@Override
public void onLocationChanged(Location location) {
//do whatever with "location"
}
No need for internet connection at all, you just need a location provider (A-GPS, GPS)
Upvotes: 0