0

アプリで「GPS の検索」を停止しようとしています。このコード行を使用しているとき:

this.locationManager.removeUpdates(this);

通知バーにまだ GPS のアイコンが表示されていて、まったく止まっていません。他に何ができますか?ありがとう!

4

3 に答える 3

3

これを渡す代わりに、位置リスナー インスタンスを次のように removeUpdate メソッドに渡す必要があります。

locationManager.removeUpdates(gpsLocationListener);

どこ

GPSLocationListener gpsLocationListener = new GPSLocationListener();

class GPSOnChangeLocationListener implements LocationListener {
           public void onLocationChanged(Location location) {}
           public void onProviderDisabled(String arg0) {}
           public void onProviderEnabled(String arg0) {}
           public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}
}
于 2012-05-29T10:54:11.873 に答える
1

私はそれを考え出した。それは私がやったことであり、それは動作します:

private void registerLocationUpdates() {
    Intent intent = new Intent(ParkOGuardActivity.class.getName()
            + ".LOCATION_READY");
    pendingIntent = PendingIntent.getBroadcast(
            getApplicationContext(), 0, intent, 0);
    // minimum every 30 minutes, 300 kilometers 
    this.locationManager.requestLocationUpdates(this.provider, 30000,
            300000, pendingIntent);
}

private void cancelLocationUpdates() {
    this.locationManager.removeUpdates(pendingIntent);
}

私を助けようとしてくれた皆さんに感謝します。

于 2012-05-29T11:48:00.477 に答える
0

試すlocationManager.removeUpdates(gpsl);

于 2012-05-29T10:54:38.543 に答える