0

I am working on an app which involves tracking of android device. I found a google's sample code for getting location updates here which is working really good and easy to implement but the problem is it stops getting location updates when mobile's GPS is turned off.

So, I want to know that is there any way to get location updates from network connection using fused location API even if the GPS of the mobile is turned off.

Thanks

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Swapnil Lanjewar
  • 646
  • 10
  • 26

2 Answers2

2

Old question but for the benefit of people who stumble upon this question. Yes you can get location updates even if the GPS is turned off. You should use LocationManager.NETWORK_PROVIDER along with LocationManager.GPS_PROVIDER. NETWORK_PROVIDER will provide you location updates when GPS is not available. You should call requestLocationUpdates on both providers. when one fails the other will provide you with location coordinates. According to android developer guide about NETWORKD_PROVIDER

This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup.

Sam
  • 2,935
  • 1
  • 19
  • 26
-1

Fused location provider tries to get best possible location which is certainly the location data from GPS. If you want location from your mobile network put the following permission in your manifest.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Theoretically, this should get you the location from the mobile network.

Talha Mir
  • 1,228
  • 11
  • 19