我試圖停止在我的應用程序中「搜索GPS」。 當我使用這行代碼:如何停止「搜索GPS」在android
this.locationManager.removeUpdates(this);
我仍然可以看到GPS的圖標在通知欄,它不是停在所有。 我還能做什麼? 謝謝!
我試圖停止在我的應用程序中「搜索GPS」。 當我使用這行代碼:如何停止「搜索GPS」在android
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) {}
}
嘗試locationManager.removeUpdates(gpsl);
我理解了它。 這就是我做了什麼,它的工作原理:
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);
}
感謝大家誰試圖幫助我。
感謝您分享解決方案。隨意標記自己的答案在這裏被接受*(當時間到了)*,[這甚至鼓勵](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-和答案 - 你自己的問題/)。通過這種方式,搜索引擎用戶很清楚爲您解答問題,而且他們不會浪費時間來理解可能無法幫助他們的答案。 – 2012-05-29 11:52:22
下調投票的原因?' – Venky
我不知道是誰做的......我沒試過。 – roiberg
它適合你嗎? – Venky