Android获取GPSStatus总是什么都不返回,为什么?

时间:2011-08-30 09:05:24

标签: android

我的代码是:

android.location.GpsStatus.Listener gpsstatusListenerGps = new android.location.GpsStatus.Listener(){         public void onGpsStatusChanged(int event){

    GpsStatus gpsStatus             = lm.getGpsStatus(null);                    

    switch (event) {
            case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                locationResult.gotSatellites(gpsStatus);
                Log.e("gpsStatus", "gpsStatus");

                lm.removeGpsStatusListener(gpsstatusListenerGps);

            for (GpsSatellite sat:lm.getGpsStatus(null).getSatellites()) {
                Log.e("STATUS", "gpsx.GpsStatus.Sat.fixed: " + sat.usedInFix());
            }

                break;
            case GpsStatus.GPS_EVENT_FIRST_FIX:
                locationResult.gotSatellites(gpsStatus);
            Log.e("FIX", "gpsx.fixed.");

            lm.removeGpsStatusListener(gpsstatusListenerGps);


            for (GpsSatellite sat:lm.getGpsStatus(null).getSatellites()) {
                Log.e("FIXX", "gpsx.GpsStatus.Sat.fixed: " + sat.usedInFix());
            }


                break;
    }

    }
};

...             Log.e( “sat.hasNext()”, “” + sat.hasNext());

        while (sat.hasNext()){
           GpsSatellite oSat = (GpsSatellite) sat.next();
           Log.e("gps",""+oSat.getSnr());   
       }

sat.hasNext总是假的。

我总是得到nullstring,所以我不能得到gpsstatuses,为什么?

0 个答案:

没有答案