Note that there are some explanatory texts on larger screens.

plurals
  1. POFind current location like google maps
    text
    copied!<p>I have one app that needs user's current location. In the application, I have registered two location providers to listen for location and additionally I have also checked for last known location too. But the app do not receive the location always. The surprising thing I found today is that, </p> <p>GPS was off </p> <p>but location from wireless network was on.</p> <p>I opened google Maps and I can see that it is showing current location so accurately. But When I opened my app, it could not get location.</p> <p>I was surprised seeing this and I think there is something google map is doing to receive location other than I have done. </p> <p>Here is how I have registered for location</p> <pre><code>locationManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); Location location = null; try { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 10, 100, this); Location location1 = locationManager .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location1 != null) location = location1; Log.v(TAG, "Network listener Enabled"); } catch (RuntimeException ee) { // TODO: handle exception Log.e(TAG, "Network Providers Disabled"); } try { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 10, 100, this); Location location1 = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); Log.v(TAG, "GPS listener enabled"); if (location1 != null) location = location1; } catch (RuntimeException e) { Log.e(TAG, "GPS not available"); } </code></pre> <p>I dont know if there are any other things that I need to do with. Please help me.</p>
 

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