onGpsStatusChanged从未调用过

时间:2013-02-24 17:30:30

标签: android android-location

我想知道我的GPS应用程序中的卫星数量。 但不知怎的,onStatusChanged的乐趣永远不会被调用。

有什么想法吗?

private class MyGpsStatusListener implements android.location.GpsStatus.Listener
{

    @Override
    public void onGpsStatusChanged(int arg0) {

        String strGpsStats = "";

        GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
        if(gpsStatus != null) {
            Iterable<GpsSatellite>satellites = gpsStatus.getSatellites();
            Iterator<GpsSatellite>sat = satellites.iterator();
            int i=0;
            while (sat.hasNext()) {
                GpsSatellite satellite = sat.next();

                strGpsStats+= (i++) + ": " + satellite.getPrn() + "," + satellite.usedInFix() + "," + satellite.getSnr() + "," + satellite.getAzimuth() + "," + satellite.getElevation()+ "\n\n";
            }

            Toast.makeText(getBaseContext(), strGpsStats, Toast.LENGTH_LONG).show();
            Log.i(T, "GPS STATUS HAS CHANGED:" + strGpsStats);
        }
    }

}

0 个答案:

没有答案