List of usage examples for android.os StrictMode setThreadPolicy
public static void setThreadPolicy(final ThreadPolicy policy)
From source file:Main.java
public static void setStrictModeOn() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectNetwork().penaltyLog() .penaltyDialog().permitDiskWrites().permitDiskReads().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); }
From source file:Main.java
public static void openStrictMode() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .penaltyLog().detectNetwork().penaltyDeath().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build()); }
From source file:Main.java
public static void enableStrictMode() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); }
From source file:Main.java
public static void setThreadPolicy() { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); }
From source file:Main.java
public static void ignoreSslErros() { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); }
From source file:Main.java
protected static void AddStrictMode() { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); }/*from www . j a v a2s.com*/ }
From source file:Main.java
public static boolean isAvailable(String urlString) throws IOException { try {// w w w. j av a2s .co m StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); URL url = new URL(urlString); HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); urlc.setRequestProperty("Connection", "close"); urlc.setConnectTimeout(1000); urlc.connect(); if (urlc.getResponseCode() == 200) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void enableStrictMode(Class... cls) { if (hasGingerbread()) { StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder().detectAll() .penaltyLog();//from w w w . j a va2 s .c o m StrictMode.VmPolicy.Builder vmPolicyBuilder = new StrictMode.VmPolicy.Builder().detectAll() .penaltyLog(); if (hasHoneycomb()) { threadPolicyBuilder.penaltyFlashScreen(); if (cls != null) { for (Class cl : cls) { vmPolicyBuilder.setClassInstanceLimit(cl, 1); } } } StrictMode.setThreadPolicy(threadPolicyBuilder.build()); StrictMode.setVmPolicy(vmPolicyBuilder.build()); } }
From source file:org.mozilla.gecko.LocaleAware.java
public static void initializeLocale(Context context) { final LocaleManager localeManager = BrowserLocaleManager.getInstance(); final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites();//from w w w. jav a2 s . co m try { localeManager.getAndApplyPersistedLocale(context); } finally { StrictMode.setThreadPolicy(savedPolicy); } }
From source file:Main.java
@TargetApi(11) public static void enableStrictMode(Class classs) { if (hasGingerbread()) { StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder().detectAll() .penaltyLog();//from w ww .ja v a2 s. co m StrictMode.VmPolicy.Builder vmPolicyBuilder = new StrictMode.VmPolicy.Builder().detectAll() .penaltyLog(); if (hasHoneycomb()) { threadPolicyBuilder.penaltyFlashScreen(); vmPolicyBuilder.setClassInstanceLimit(classs, 1); } StrictMode.setThreadPolicy(threadPolicyBuilder.build()); StrictMode.setVmPolicy(vmPolicyBuilder.build()); } }