create a service
ublic class LogoutService extends Service{
public static CountDownTimer timer;
private final String TAG="Service";
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
timer = new CountDownTimer(1 *60 * 1000, 1000) {
public void onTick(long millisUntilFinished) {
//Some code
Log.v(TAG, "Service Started");
}
public void onFinish() {
Log.v(TAG, "Call Logout by Service");
// Code for Logout
stopSelf();
}
};
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
then add the code for all activity
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
try {
LogoutService.timer.start();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
LogoutService.timer.cancel();
}
here after certain minutes the first page will be displayed automatically