Skip to content

Instantly share code, notes, and snippets.

@gvr23
Last active December 28, 2017 16:04
Show Gist options
  • Save gvr23/d1dd7143e0faabfe7fe422086cbf0745 to your computer and use it in GitHub Desktop.
Save gvr23/d1dd7143e0faabfe7fe422086cbf0745 to your computer and use it in GitHub Desktop.
For restarting in an idle situation
ANDROID
===============================================================================================================================
protected void reiniciarTimer(){
cancelarTimer();
timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
irPantalla(PromocionesActivity.class);
}
};
timer.schedule(timerTask, Constantes.TIEMPO_INACTIVIDAD * 1000);
}
protected void cancelarTimer(){
if(timer != null){
timer.cancel();
timer.purge();
}
}
GO TO A CERTAIN ACTIVITY
===============================================================================================================================
protected void irPantalla(Class clase){
startActivity(new Intent(this, clase));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment