0
我有A Activity
和B Activity
,兩者都實施LocationListener
。因此,無論有2活動通知GPS狀態更改
@Override
public void onProviderDisabled(String provider) {
// Open AlertDialog
}
我開始B Activity
從A Activity
。當我關閉B
上的GPS時,它將打開AlertDialog
,如代碼所示,然後打開GPS並關閉AlertDialog
。現在,當我返回到A Activity
時,它也顯示AlertDialog
,因爲它在幾秒前關閉GPS時會收到通知。
我想即使我打開B
從A
,A
沒有完全銷燬,並保存在後臺。那麼如何解決這個問題,而不需要從Activity Backstack 中刪除A
?應用只能在屏幕上的任何活動上打開AlertDialog
。
停止監聽活動A的的onPause或方法的onStop GPS。並開始在onResume中收聽。 –
@sourabhbans是的,我只是試圖。因爲我停下來聽'onDestroy' –
在onStop上試試.. –