onLocationChanged只是调用一次使用的网络供应商 [英] onLocationChanged just called once using network provider

查看:544
本文介绍了onLocationChanged只是调用一次使用的网络供应商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用位置监听器和位置管理器有问题。

i have a problem using location listener and location manager.

我使用类,我在网上

public class MyLocationListener implements LocationListener
{
    public void onLocationChanged(Location location) {
        home_text.setText("Location Change");
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }
}

当我使用GPS提供商,它工作正常。

when i use gps provider, it works fine

locationListener = new MyLocationListener();
locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,1, locationListener);

当我使用网络提供者,onLocationChanged只是在开始调用一次,永远不会再被调用。

when i use network provider, the onLocationChanged just called once at the start and never called again.

locationListener = new MyLocationListener();
locationManager =    (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1000,1, locationListener);

虽然,当我打开使用这两种方法中的地图,它仍然可以找到我的当前位置和更新地图。

although, when i open the maps using both method, it still can find my current location and update the maps.

googleMap.setMyLocationEnabled(true);

请帮我...

推荐答案

LocationManager.NETWORK_PROVIDER试图查找使用蜂窝网络塔和周围的WiFi网络的设备。如果他们都不改变,那么您将不会收到任何更新。

LocationManager.NETWORK_PROVIDER tries to locate the device using cell network towers and Wifi networks around. If neither of them change, then you won't receive any update.

你问的更新和云游四方(你可能需要考虑在你的地方有点走)?

Did you ask for updates and roam around (you might need to take a little walk around your place) ?

使用GPS,作为信号增强,并获得更多,更准确,您会收到更新,即使你不动。

With GPS, as the signal strengthens and get more and more accurate, you will receive updates even if you don't move.

这篇关于onLocationChanged只是调用一次使用的网络供应商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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