1
我正在使用這段代碼來阻止gps定位問題,有時android會殺死我的進程再次啓動它......並且句柄變爲無效......使得無法停止gps .. 。我怎樣才能做到這一點 ?Gps位置監聽器停止
這裏是代碼:
lm.removeUpdates(locationListener);
locationListener = null;
我正在使用這段代碼來阻止gps定位問題,有時android會殺死我的進程再次啓動它......並且句柄變爲無效......使得無法停止gps .. 。我怎樣才能做到這一點 ?Gps位置監聽器停止
這裏是代碼:
lm.removeUpdates(locationListener);
locationListener = null;
試戴
locationManager.removeUpdates(locListener);
if (locListener != null) {
locListener = null;
}
if (locationManager != null) {
locationManager = null;
}
並確保您初始化處理程序onResume()
而不是onCreate()
也把上面這段代碼onLocationChanged()
因爲,如你所說,你不需要gps(至少相當一段時間)。
@ opc0de:有用嗎?讓我知道如果它或nt。或者你可以將它標記爲接受。 – Rajkiran 2012-03-17 20:06:25