import java.util.Timer; import java.util.TimerTask; private Timer myTimer; @Override protected void onCreate(Bundle savedInstanceState) { myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { TimerMethod(); } }, 0, 1000); } private void TimerMethod() { //This method is called directly by the timer //and runs in the same thread as the timer. this.runOnUiThread(Timer_Tick); } private Runnable Timer_Tick = new Runnable() { public void run() { //This method runs in the same thread as the UI. //Do something to the UI thread here Log.e(TAG, "********************************"); } };
Tuesday, March 21, 2017
android timer ui thread
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment