不是在模拟器运行的,是在真机器上,gps开始搜索信号,直到可以在onLocationChanged中得到经纬度信息,然后把机器拿到房间里,gps信号中断,整个过程写在onStatusChanged里的事件一次也不触发

解决方案 »

  1.   

    可能是你设置onStatusChanged事件的最短距离或最短时间比较大,所以从有经纬度到房间那段距离还不够
      

  2.   


    这个跟有经纬度有关系吗,不是onlocationchange啊是onStatusChanged
      

  3.   

    I have defined LocationListener like this one and set through requestLocationUpdates() for both providers GPS and NETWORK.public class geoListener implements LocationListener {
      public void onStatusChanged(String provider, int status, Bundle extras) {
        Log.d("test", "Status changed to " + status);
      }  public void onLocationChanged(Location location) {
        // do some things
      }
    }What happend ON REAL DEVICE:
    - Nothing. onStatusChanged is never called. Not when GPS gets fixed, not when GPS lost fix... just never. Other methods (eg. onLocationChanged) of used LocationListener are working properly.What happend ON EMULATOR:
    - onStatusChanged is called when I manually set location using ddms.Expecting behavior ON REAL DEVICE:
    - onStatusChanged should be called everytime the provider changed status between available or unavailable (temporarily or permanently). For example when GPS gets or lost fix.Operating system ON REAL DEVICE:
    - Android 2.2, FRF85B, Google Nexus One
    Comment 1 by [email protected], Aug 12, 2010 I'm also experiencing this issue, on a HTC Desire, Android 2.2
    Comment 2 by [email protected], Sep 20, 2010 I am also facing the same issue on my Nexus one, Android 2.2
    Comment 3 by [email protected], Oct 9, 2010 This issue is also present on Android 2.2.1, build FRG83 on a Nexus One.
    Comment 4 by [email protected], Feb 10, 2011 Same behavior on Nexus S.  LocationListener is registered but onStatusChanged is never called.  
    Nexus S Android 2.3.1 
    Kernel Version 2.6.35.7-g7f1638a
    Build Number GRH78OnStatusChanged DOES get called on the Samsung Galaxy S running 2.1  
    Comment 5 by [email protected], Feb 20, 2011 Same issue on SH-03C, Android 2.1-update1.
    OnStatusChanged does NOT get called.
    Comment 6 by [email protected], May 19, 2011 Exactly the same issue on HTC Desire Android 2.2
    onStatusChanged is not called.
    Comment 8 by [email protected], Jul 28, 2011 Same issue on Samsung Galaxy S running 2.2
    Comment 10 by [email protected], Aug 3, 2011 Updated to 2.3.3, still the same
    Also tested on Galaxy S 2 with 2.3.3, no luck.
    Also tested on old G1 HTC 1.6, it works on that device. Strange..
    Comment 11 by [email protected], Aug 6, 2011 On Nexus One 2.3.4 onStatusChanged is not called too - what is more interesting it did work on Android 1.6other finding:
    after acquiring GpsSatellite objects from GpsStatus none of them have isUsedInFix set to false
      

  4.   

    如果开发GPS应用方面的软件
    ①先要获取一个管理器:
    LocationManager locationManager  = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    ②再定义一个监听:
    LocationListener locationListener = new LocationListener() {
                            @Override
                            public void onStatusChanged(String provider, int status, Bundle extras) {
                                    switch (status) {
                                    // GPS状态为可见时
                                    case LocationProvider.AVAILABLE:
                                            Log.e("TAG", "当前GPS状态为可见状态");
                                            et01.setText("LocationProvider.AVAILABLE");
                                            break;
                                    // GPS状态为服务区外时
                                    case LocationProvider.OUT_OF_SERVICE:
                                            Log.e("TAG", "当前GPS状态为服务区外状态");
                                            et01.setText("LocationProvider.OUT_OF_SERVICE");
                                            break;
                                    // GPS状态为暂停服务时
                                    case LocationProvider.TEMPORARILY_UNAVAILABLE:
                                            Log.e("TAG", "当前GPS状态为暂停服务状态");
                                            et01.setText("LocationProvider.TEMPORARILY_UNAVAILABLE");
                                            break;
                                    }
                            }                        @Override
                            public void onProviderEnabled(String provider) {
                                    Log.e("TAG", "onProviderEnabled");
                                    et01.setText("onProviderEnabled");
                            }                        @Override
                            public void onProviderDisabled(String provider) {
                                    Log.e("TAG", "onProviderDisabled");
                                    et01.setText("onProviderDisabled");
                            }                        @Override
                            public void onLocationChanged(Location location) {
                                    // updateView(location);
                                    Log.e("TAG", "时间:" + location.getTime());
                                    Log.e("TAG", "经度:" + location.getLongitude());
                                    Log.e("TAG", "纬度:" + location.getLatitude());
                                    Log.e("TAG", "海拔:" + location.getAltitude());
                                    et01.setText("时间:" + location.getTime() + "经度:" + location.getLongitude() + "纬度:"
                                                    + location.getLatitude() + "海拔:" + location.getAltitude());
                            }
                    };
    ③邦定监听到管理器上(provider直接使用GPS_PROVIDER,不考虑NETWORK_PROVIDER):
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);问题是,测试时(真实设备非虚拟设备),似乎永远无法触发locationListener的onStatusChanged方法,请教高手,何时能触发这个方法,再就解释一下方法中的各个状态,多谢!!!
      

  5.   

    wen ti jie jue le ma lou zhu