How to kill a PostDelayed Method in Android -


this question has answer here:

i used posteddelayed method refresh activity, works fine. problem when press button postdelayed method call previous activity..

//handler 30000 milli-secs post delay refreshment of activity

mhandler.postdelayed(new runnable() { public void run() {                dostuff();          }             }, 30000);     }  protected void dostuff() { intent intent = getintent(); finish();startactivity(intent); toast.maketext(getapplicationcontext(), "refreshed", toast.length_long).show(); }  public void onbackpressed() {         super.onbackpressed();         finish();         mhandler.removecallbacks(null);         }  protected void onstop() {             mhandler.removecallbacks(null);         super.onstop();     } 

you use may you

   runnable runobj=new runnable() { public void run() {  dostuff();   }   };  mhandler.postdelayed(runobj, 30000);    } public void onbackpressed()  { super.onbackpressed(); mhandler.removecallbacks(runobj); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -