set Strict Mode for Thread Policy - Android Android OS

Android examples for Android OS:Thread

Description

set Strict Mode for Thread Policy

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.StrictMode;

public class Main {
    @TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public static void setStrictMode() {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll().penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectAll().penaltyLog().build());
    }/* w w  w.ja  va  2 s .c  o m*/
}

Related Tutorials