アプリで「GPS の検索」を停止しようとしています。このコード行を使用しているとき:
this.locationManager.removeUpdates(this);
通知バーにまだ GPS のアイコンが表示されていて、まったく止まっていません。他に何ができますか?ありがとう!
これを渡す代わりに、位置リスナー インスタンスを次のように 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) {}
}
私はそれを考え出した。それは私がやったことであり、それは動作します:
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);
}
私を助けようとしてくれた皆さんに感謝します。
試すlocationManager.removeUpdates(gpsl);