Network provider does not work in android

I need to make an Android app in which I need to find the current location of the user. To do this, I first use the GPS provider, but if it is not available, I return to the network provider. Now on my phone there were cases when even the network provider did not work, and the operator network_enabled = lm .isProviderEnabled (LocationManager.NETWORK_PROVIDER);

gives a false value.

My question

I can still make phone calls, so my network provider is working fine. What do I need to know in what conditions does the network provider not work? what are the possible scenarios when the network provider on my Android device is not working to provide me with my coordinates.

early

+6
source share
2 answers

Two days were puzzled by this problem. I have found a solution. Just go to Settings → Location and Security and turn on the “Use wireless networks” flag in the “My location” group.

But now I have a question: what is the default state of this flag? It will be very sad if the application should ask the user to enable this flag.

+9
source

You need to activate the location through network providers in the Settings menu, and if it is disabled at the beginning of the application, you can show Toast to notify the user

0
source

Source: https://habr.com/ru/post/889418/


All Articles