[Android Memory] Android's Strictmode

Source: Internet
Author: User

The Strictmode introduced after Android 2.3 limits access to the network.

 Public voidonCreate () {if(Developer_mode) {Strictmode.setthreadpolicy (NewStrictMode.ThreadPolicy.Builder (). Detectdiskreads (). Detectdiskwrites () . Detectnetwork ()//or. Detectall () for all detectable problems. Penaltylog (). build ()); Strictmode.setvmpolicy (NewStrictMode.VmPolicy.Builder (). Detectleakedsqlliteobjects (). Detectleakedclosableobje     CTS (). Penaltylog (). Penaltydeath (). build ()); }     Super. OnCreate ();} 

1. After the 2.3 version joined the Strictmode class, and in 3.0 on the network can feel more stringent restrictions, more query API on the Strictmode;
2. The entire project program is useful only if you need to put this code in the OnCreate of the entry activity where your project is running. Do not need to add each activity inside.

The 3.StrictMode class is typically used for debugging, and will print a lot of messages during the program's run, which is where you need to improve your project program. In Android projects, the best thing is to separate the interface from the background loader. In short, if your program code is very much in line with the Android specification, then you can completely not use the above code ...

[Android Memory] Android Strictmode

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.