isProviderEnabled(LocationManager.NETWORK_PROVIDER) 返回 false [英] isProviderEnabled(LocationManager.NETWORK_PROVIDER) return false

查看:77
本文介绍了isProviderEnabled(LocationManager.NETWORK_PROVIDER) 返回 false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 NETWORK_PROVIDER 获取该地点的 latitudelongitude.

I am using NETWORK_PROVIDER to get latitude and longitude of the place.

我已经检查了位置和安全"中的设置并启用了使用无线网络".但是 "isProviderEnabled(LocationManager.NETWORK_PROVIDER)" 总是返回 false.

I'v already check the setting in the "location & security" and enable "use wireless networks". But "isProviderEnabled(LocationManager.NETWORK_PROVIDER)" always return false.

谁能帮帮我?提前谢谢你!

Can anyone help me? Thank you in advance!

这是我的代码:

LocationManager locManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean isEnableGPS=locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean isEnableNTW=locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Log.d(TAG, isEnableGPS+", "+isEnableNTW);

AndroidMainfest.xml 中的权限

permission in the AndroidMainfest.xml

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

推荐答案

确保在手机设置中启用了基于网络的位置.您可以检测到这种情况,并在您确实需要时提示用户启用它.

Make sure that network based location is enabled in the phone's settings. You can detect this situation and prompt the user to enable it if you really need it.

我相信这是启动此活动的代码行.

I believe this is the line of code to launch this activity.

activity.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);

ACTION_LOCATION_SOURCE_SETTINGS

这篇文章解释了它http://emobiledude.com/fix-waiting-for-location-in-google-maps-after-android-4-2-update/

这篇关于isProviderEnabled(LocationManager.NETWORK_PROVIDER) 返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆