0
我有一個類中有一個方法,其中有一個計時器。當調用該方法時,計時器將啓動並永久啓動,但當應用程序完全關閉時,它會停止並在應用程序重新打開時不倒計數。有沒有辦法檢查計時器是否在之前滴答滴答,並現在使用共享首選項或類似的東西打勾?我不知道。如何在應用程序停止後讓計時器繼續倒計時?
所以基本上我該如何使應用程序停止後,計時器繼續計數?
方法下面
公衆詮釋shipAdd(){ 如果(計數器> = addSpend){
counter -= addSpend;
addSpend += addSpend;
counterPerSec +=addAmount;
addClick += addClick;
test++;
// The count down timer below
new TimerClass(addTime, 1000) {
public void onFinish() {
counter += addAmount;
this.start();
}
}.start();
} else if (counter < addSpend) {
}
return addSpend;
}
退房[服務](HTTP:/ /developer.android.com/guide/components/services.ht毫升) – aProperFox 2014-10-10 17:53:24
我只希望它在應用程序打開時(UI已打開) – 2014-10-10 18:19:35
你說你希望它在應用程序停止時運行? – aProperFox 2014-10-10 18:22:23