由於用戶處於非活動狀態,15分鐘後如何在android中使用timer進行自動註銷?由於在android中不活動而導致15分鐘後自動註銷
我使用這個婁代碼在我loginActivity.java
public class BackgroundProcessingService extends Service {
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
timer = new CountDownTimer(5 *60 * 1000, 1000) {
public void onTick(long millisUntilFinished) {
//Some code
//inactivity = true;
timer.start();
Log.v("Timer::", "Started");
}
public void onFinish() {
//Logout
Intent intent = new Intent(LoginActivity.this,HomePageActivity.class);
startActivity(intent);
//inactivity = false;
timer.cancel();
Log.v("Timer::", "Stoped");
}
};
return null;
}
}
和的onclick登錄按鈕的我呼籲服務的意圖。
請指點......
此類型的錯誤消息之後15分鐘
所示
我相信你正在尋找不活動,而不是anactivity – Krishnabhadra
@Krishnabhadra是其不活動。 – Rash
啓動一項服務並在其中啓動一個計時器並在那裏處理您的會話。 –