Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get Updated location & Disable GPS after getting it in android?
    primarykey
    data
    text
    <p>friends,</p> <p>i am using following code to get GPS location </p> <p>it is causing two problems</p> <p>1) when my location is changed / I move my phone from one area to another I dont get updated gps location(latitude/longitude)</p> <p>2) after getting gps location my gps of phone is enabled how to disable it?</p> <pre><code> double MyDeviceLatitude,MyDeviceLongitude; public void GetGPSLocation() { LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener myLocationListener = new CurrentLocationListener(); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30, 30, myLocationListener); Location currentLocation = locationManager.getLastKnownLocation("gps"); if(currentLocation != null) { MyDeviceLatitude = currentLocation.getLatitude(); MyDeviceLongitude = currentLocation.getLongitude(); }else { currentLocation = locationManager.getLastKnownLocation("network"); MyDeviceLatitude = currentLocation.getLatitude(); MyDeviceLongitude = currentLocation.getLongitude(); } public class CurrentLocationListener implements LocationListener{ public void onLocationChanged(Location argLocation) { if (argLocation != null) { MyDeviceLatitude = argLocation.getLatitude(); MyDeviceLongitude = argLocation.getLongitude(); } } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle arg2) { } } </code></pre> <p>}</p> <p>any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload