Answer the question
In order to leave comments, you need to log in
How to check if geolocation is enabled?
Hello. Tell me please. How to check if geolocation is enabled (needed to display Wifi networks).
Why is locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) always returning false even if geolocation is enabled.
Permissions are enabled.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
|| checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION},
2222);
}
if (!locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question