Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yakivmospan/f4a0385877242a305150275520493173 to your computer and use it in GitHub Desktop.
Save yakivmospan/f4a0385877242a305150275520493173 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