Some details that need attention; some small mistakes, hard to detect (Android sharedpreferences, Thread, Toast, Asynctask)

Source: Internet
Author: User

1, Sharedpreferences Prefs.edit (). putstring ("SHAKE", Object.getstring ("SHAKE")).commit ();Sharedpreferences When the value is stored, put in, must commit, otherwise it will not take effect.
2. Thread new Thread () {public void Run () { 。。。。。   }; }.start ();thread, a long time ago I new a thread, the result forget start, I tangled for a long time ... Only to find that there was no start. Later, I remember the thread to start, the result forgot to run, in-line write what code all error, finally found that there is no run.
3, Toast Toast.maketext (Getapplicationcontext (), err_msg, Toast.length_long).Show ();toast, many times I use toast as a user friendly hint. Strange things just happened, I have written toast, the results did not pop out. At first, I thought it was the context, so I tried the current activity contexts and getapplicationcontext, or did not bounce out. The last discovery was to forget the show.    Ah, how painful the understanding ...
4, Asynctask new Asyncgetimages ().execute (jsonurl); asynchronous task class, new after, to execute.

Some details that need attention; some small mistakes, hard to detect (Android sharedpreferences, Thread, Toast, Asynctask)

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.