How to kill a PostDelayed Method in Android -
this question has answer here:
- post delay method - android 3 answers
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
Post a Comment