0

GPS アプリで衛星の数を知りたいです。しかし、どういうわけか onGpsStatusChanged 関数が呼び出されることはありません。

何か案は?

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);
        }
    }

}
4

0 に答える 0