B
B
Bogdan2019-04-09 20:59:17
Android
Bogdan, 2019-04-09 20:59:17

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));
       }

Thank you.
PS I looked, for some reason there is no choice on the device or GPS or Network? And how then can you check the included geolocation?
5cace32e211a4017219460.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question