Skip to content

Instantly share code, notes, and snippets.

@flaviocdc
Last active December 17, 2015 03:18
Show Gist options
  • Select an option

  • Save flaviocdc/5541824 to your computer and use it in GitHub Desktop.

Select an option

Save flaviocdc/5541824 to your computer and use it in GitHub Desktop.
private Handler handler;
@Backgroud public void atualizarEstadoCasa() {
// ir no servidor
// para atualizar a tela vc tem que fazer na thread a UI
atualizarTelaComEstadoDaCasa();
// agendar uma nova atualizacao
handler.postDelayed(20000, new Runnable() {
public void run() { atualizarEstadoCasa()
});
}
@UiThread
public void atualizarTelaComEstadoDaCasa()
{
// atualizar a tela
}
public void onCreate(...) {
handler = new Handler();
handler.postDelayed(20000, new Runnable() {
public void run() { atualizarEstadoCasa()
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment