1

I am using this code to check if location services are enabled

public static boolean isLocationsEnabled(Context context) {
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
return lm.isProviderEnabled(LocationManager.GPS_PROVIDER) && lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
}

if this returns false I show an alert & redirect to Location Settings page using activityresultlauncher & in callback if the location is enabled the method returns true & I proceed to get the location It works on Android 12 devices as well, in Android 13 simulator also it works but in Samsung A52 Android 13 it still return false even after enabling location.

jaroos
  • 41
  • 3

1 Answers1

0

In the some phone as like as Samsung A7, beside of on/off switch for enable or disable location accessiblity, there is a "Location methdo" with three type of value:

  1. High accuracy
  2. Battery saving
  3. Device Only

In which only first option use the GPS module. So if you want get true value when call:

isProviderEnabled(LocationManager.GPS_PROVIDER)

you need to change Location Method to the "High Accuracy" instead of Battery Saving or Device Only. Pay attention that the Location Method option maybe not available in all phone's brand or maybe available with defferent name!

Ali Maddi
  • 309
  • 3
  • 8