LocationManager禁用了NETWORK_PROVIDER [英] LocationManager gives NETWORK_PROVIDER disabled

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

问题描述

我需要通过3G或WIFI检索用户的位置.

I need to retrieve user's location by 3G or WIFI.

这就是我想要做的:

LocationListener locationListener = new LocationListener() {
            public void onLocationChanged(Location location) {
                manageLocation(location);
            }

            public void onStatusChanged(String provider, int status, Bundle extras) {

            }

            public void onProviderEnabled(String provider) {

            }

            public void onProviderDisabled(String provider) {

            }
        };
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

问题在于,唯一被调用的回调是onProviderDisabledLocationManager.NETWORK_PROVIDER作为参数.

The problem is that the only callback that is called is onProviderDisabled giving LocationManager.NETWORK_PROVIDER as parameter.

清单中已获得我的许可:

I've got that permission in the manifest:

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

如何在应用程序中启用该类型的位置?

How can I enable that type of location in my application?

推荐答案

用户需要进入设备的设置"应用并启用位置提供程序.您不能直接启用该功能.

The user needs to go into the device's Settings app and enable location providers. You cannot enable that yourself directly.

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

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