import android.content.Context; import android.content.pm.ApplicationInfo; import android.os.StrictMode; /** * @author chris * */ public class StrictModeWrapper { public static void start(Context context) { // Check if android:debuggable is set to true. int appFlags = context.getApplicationInfo().flags; if ((appFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() // .detectDiskWrites() // .detectNetwork() // .penaltyLog() // .penaltyDeathOnNetwork() // .penaltyDeath() // .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() // .penaltyLog() // .penaltyDeath() // .build()); } } }