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.