isProviderEnabled(LocationManager.GPS_PROVIDER) always returns false in android 2.3

那年仲夏 提交于 2020-01-14 03:56:23

问题


I am trying to redirect the user to Location Settings Screen using an

Alert Dialog to so that he can enable the GPS, But after I enable

the Use Wireless Network checkbox on Api 2.3 and return to previous Activity

its again showing me the Alert Dialog for settings screen.

because this line :

isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 

is always returning false.

I am using below code to redirect to Locations Setting.

Intent im=new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(im);

But on Api 5.1.1 the same code is working fine and returning true

Why is it so ?

Thanks In Advance...


回答1:


Actually the device with version 2.3 that I was using for testing was not having GPS so I was always getting the value false and I figured it out when I accidently read my phone's specification



来源:https://stackoverflow.com/questions/34289165/isproviderenabledlocationmanager-gps-provider-always-returns-false-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!