Skip to content

Instantly share code, notes, and snippets.

@dmytrodanylyk
Created January 18, 2017 13:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dmytrodanylyk/94476bc3154871390d6aaf3b1a976fa6 to your computer and use it in GitHub Desktop.
Save dmytrodanylyk/94476bc3154871390d6aaf3b1a976fa6 to your computer and use it in GitHub Desktop.
Strict Mode
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectCustomSlowCalls()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.VmPolicy.Builder vmPolicy = new StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.detectLeakedClosableObjects();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
vmPolicy = vmPolicy.detectCleartextNetwork();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
vmPolicy = vmPolicy.detectFileUriExposure();
}
StrictMode.setVmPolicy(vmPolicy.penaltyLog().build());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment