android - TimerTask doesn't take effect -


here's code:

public class somename extends mapactivity implements onclicklistener, ontouchlistener{ public timer t1 = new timer(); public timertask tt; public long interval = 5000; @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.map);     timer(); } public final void timer() {       t1 = new timer();     tt = new timertask() {         @override         public void run() {             systemclick();         }     };     t1.scheduleatfixedrate(tt, 10000, interval); }  public void systemclick() {       toast.maketext(getapplicationcontext(),"system button clicked", 5).show(); } 

actually, want call function, refresh location.

but can't understand why never toast on screen. i'm new android.

thanks help.

use handler in activity

final handler handlerforadd = new handler(); runnable runnableforadd  = new runnable() {     @override     public void run() {         handlerforadd.postdelayed(this, 1000);     }    };  handlerforadd.postdelayed(runnableforadd, 0); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -