LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) is not reliable, why?

前端 未结 4 1301
孤城傲影
孤城傲影 2020-12-06 02:55

One user of my app reported that app tells network for location is off even he did turn it on. He sent me few screen shots and they made me think;

LocationMa         


        
4条回答
  •  我在风中等你
    2020-12-06 02:57

    Developer support provided by Sharp corporation is excellent and they answered to my question in less than 48 hours.

    This is what I got from them.

    There are 2 conditions must be met that LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) returns true.

    1. Some internal state is ready for network location.
    2. Network location is enabled on setting screen.

    Second one is obvious. But first one is not. They told how to simulate first one is negative. You can confirm the issue with steps shown below and running my test app (please see my question for link to download).

    • Open settings of you phone.
    • Tap Applications.
    • Tap All tab.
    • Find "Network Location", tap it.
    • Tap "Disable".
    • Reboot your phone.
    • Run test app.

    For reason I can't understand the user's phone failed to do something related to first condition shown above and exhibits the issue.

    Conclusion:

    LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) is reliable. And be aware, Secure.LOCATION_PROVIDERS_ALLOWED is less reliable.

提交回复
热议问题