MyLocationOverlay不是要求onProviderDisabled [英] MyLocationOverlay not calling onProviderDisabled

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

问题描述

这是我的code,其行为有些奇怪:

This is my code that behaves a little strange:

locationOverlay = new MyLocationOverlay(this, map) {
    @Override
    public void onLocationChanged(Location location) {
        super.onLocationChanged(location);
        updatePosition(locationOverlay.getMyLocation());
    }

    @Override
    public void onProviderDisabled(String provider) {
        if(provider.equals(LocationManager.GPS_PROVIDER))
            showNoGPSWarning();
    }
};

showNoGPSWarning 显示一个对话框,询问是否GPS应该启用(如)。结果
一切wokrs完全正常,除非我开始活动与在 showNoGPSWarning()对话框GPS残疾人和preSS否。然后,我的应用程序不听GPS变化的。

showNoGPSWarning shows a Dialog that asks if GPS should be enabled (like this).
Everything wokrs perfectly fine except if I start the Activity with GPS disabled and press "No" in the showNoGPSWarning() dialog. Then my App doesn't listen to GPS changes at all.

如果我打开它,什么都不会发生。谷歌地图API不尝试获取GPS信号。如果我把它背过,没有再次发生, onProviderDisabled()不叫。结果
正如我所说的,这是出现这种情况的唯一途径,如果我它工作在对话框中preSS是。结果
因此,如何影响我的对话我的应用程序的行为?

If I turn it on, nothing happens. The Google maps API doesn't try to get a GPS signal. If I turn it back off, nothing happens again, onProviderDisabled() is not called.
As I said, this is the only way that happens, if I press "Yes" in the dialog it works.
So how is my dialog affecting the behavior of my App?.

推荐答案

再次尝试请求位置更新时,您preSS是/否像下面。希望它帮助。

Once again try to request for location updates when you press yes/no like below. Hope it helps.

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 2000.0f, myLocationListener);

这篇关于MyLocationOverlay不是要求onProviderDisabled的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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