Android : App logout in background

on Thursday, August 21, 2014


Aim: For App to logout user in background, hence when user select HOME button to exit app. Counter will start and logout user. Help greatly appreciated


Issue: Unable to Run



public void IdleLogout(){
Timer timer = new Timer();

@Override
protected @ onPause() {
super.onPause();
//Timer starts count when Home Button is selected
int seconds = 60;
timer.schedule(new StartCounting(), 60*1000);
}
}
class StartCounting extends TimerTask{

@Override
public void run() {
// TODO Auto-generated method stub
Intent intent_login= new Intent(context, RootActivity.class);
//CLOSE ALL OTHER ACTIVITIES AND BRING THE ACTIVITY BEING LAUNCHED TO THE TOP
intent_login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent_login);
}
}

0 comments:

Post a Comment