0

I would like to get the location of a smartphone (service runs in background) if location is turned off. Is there a way to automatically activate the Location service if it is turned off? For locating the user the FusedLocationProvider is used.

I guess that there is no chance to get the location by WiFi, GPS or cell towers if the location sensor is turned off.

JavaForAndroid
  • 1,111
  • 2
  • 20
  • 42
  • in Android O background service is not working. so no any method for it. – Ricky Patel Sep 19 '17 at 10:46
  • Possible duplicate of [How do I get the current GPS location programmatically in Android?](https://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android) – Somesh Kumar Sep 19 '17 at 10:48
  • Even for Android Oreo you may turn on GPS if root available. This is actually universal for all recent Androids, at least Android Ice Cream and later. – OGP Apr 25 '18 at 10:00

1 Answers1

0

The answer is you can't turn on the location automatically. The user has to give permission that's why it comes under PROTECTION_DANGEROUS.

Kunu
  • 5,078
  • 6
  • 33
  • 61