Android yellow warning hint of obsessive-compulsive disorder

Source: Internet
Author: User

When writing code, do not want the whole project is full of yellow exclamation points, then, open the project, people feel that the whole project is not clear.

so write this post, will usually encounter the warning of all the summary together.

1:handler

This Handler class should is static or leaks might occur:incominghandler @SuppressLint ("Handlerleak") Private Handler ha Ndler = new Handler () {@Overridepublic void Handlemessage (Message msg) {};};

Workaround:

Private Handler Handler = new Handler (new Handler.callback () {@Overridepublic Boolean handlemessage (Message msg) {return F Alse;}});

2:simpledateformat

To get local formatting with getdateinstance (), getdatetimeinstance (),//or//Gettimeinstance (), or use new Simpledatef Ormat (String template,locale  Locale) with for example locale.us for ASCII dates. @SuppressLint ("SimpleDateFormat") SimpleDateFormat SimpleDateFormat = new SimpleDateFormat ("Yyyy-mm-ddhh:mm:ss");

Workaround:

SimpleDateFormat Newsimpledateformat = new SimpleDateFormat ("yyyy mm month dd hh", Locale.getdefault ());

  

Android yellow warning hint of obsessive-compulsive disorder

Related Article

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.