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