What to look for when Android creates activity

Source: Internet
Author: User
1. Load the UI in OnCreate () and refresh the UI in OnStart ()/onresume ()
2. In OnCreate () with handler delay request data, data processing is best two times callback callback (first time from DB, second from the network)
3. Create handler in the activity as little as possible, create a uihandler, a background handlerthread enough
4. All asynchronous tasks are written in a runnable, using their own application background thread pool, instead of the direct new thread () in the activity
5. Asynchronous runnable can also be referred to handlerthread processing, but note its callback sequence and delay, again remind try not to new Thread ()
6.Activity at the end of the time as far as possible to manually release resources, it is best to destroy Uihandler and Handlerthread.
7. Use adapter's Notifydatasetchange () sparingly
8. If you really want to use thread, use Asyncthread instead of new thread ()

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.