Android-tip-the use of various clock

Source: Internet
Author: User
Reference: http://developer.android.com/reference/android/os/SystemClock.html

system.currenttimemills () the number of milliseconds that this function obtains is determined by the date and time of the current system. It can be changed by Systemclock.setcurrenttimemillis (). If you need an accurate timer, you must not use it .

Systemclock.uptimemillis () This clock is often used to animate, and Animationutils.currentanimationtimemillis () is implemented by this method. it represents the number of milliseconds from the start of the system startup, and when the system enters deep sleep, the clock stops , such as the CPU off, the monitor is off, the device waits for external input, and so on. It is the basis of many timers, such as Thread.Sleep (), object.wait (), System.nanotime (). If our timer does not need to go on while the device is hibernating, it is appropriate to use this function as a timer.

systemclock.elapsedrealtime () This clock is in time to operate normally when the CPU is in power-saving mode or deep sleep . So if we need an accurate timer, then use this method.

Android-tip-the use of various clock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.