Handler. Just don't use Timer, Handler is the Android-centric mechanism.
On Thu, Mar 22, 2012 at 10:53 PM, Perumss Naren <peru2...@gmail.com> wrote: > Hi , > > which way is best in performance is Handler or timer i need > to update textview as timer every second need to update time so which one > will be best please tell the reason. because i need the reason thanks in > advance > > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > timer = (TextView) findViewById(R.id.timer); > > // handler.post(mRunnable); > task = new UpdateTimeTask(); > handler.post(task); > } > > > private Runnable mRunnable = new Runnable() { > @Override > public void run() { > timer.setText(dateFormat.format(new Date())); > handler.postDelayed(mRunnable, 1000); > } > }; > > class UpdateTimeTask extends TimerTask { > public void run() { > timer.setText(dateFormat.format(new Date())); > handler.postDelayed(task, 1000); > } > } > > > -- > Regards, > > Perumal.N > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en