if(mHostname != null){ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
@Override public void onReady(Bundle savedInstanceState) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectNetwork() .penaltyDeath() .build()); if (getSupportFragmentManager().findFragmentById(android.R.id.content)==null) { getSupportFragmentManager().beginTransaction() .add(android.R.id.content, new DownloadFragment()).commit(); } }
try{ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);
.build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects()
.build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects()
.build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects()
@Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); } Once.initialise(this); } }
private void initStrictMode() { if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder() .detectAll() // .penaltyDialog() // 弹出违规提示对话框 .penaltyLog() // 在logcat中打印违规异常信息 .build()); StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .build()); } }
private void setupStrictMode() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() // .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyFlashScreen() .build()); }
int targetSdkVersion = data.appInfo.targetSdkVersion; if (targetSdkVersion < Build.VERSION_CODES.GINGERBREAD) { StrictMode.ThreadPolicy newPolicy = new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy()).permitNetwork().build(); StrictMode.setThreadPolicy(newPolicy);
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate start"); if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); } applicationComponent = DaggerApplicationComponent.builder() .applicationModule(new ApplicationModule(this)) .build(); //初始化Stetho BuildConfig.STETHO.init(this.getApplicationContext()); weatherApplicationInstance = this; //初始化ApiClient ApiConfiguration apiConfiguration = ApiConfiguration.builder() // .dataSourceType(ApiConstants.WEATHER_DATA_SOURCE_TYPE_MI) // .dataSourceType(ApiConstants.WEATHER_DATA_SOURCE_TYPE_KNOW) .dataSourceType(ApiConstants.WEATHER_DATA_SOURCE_TYPE_ENVIRONMENT_CLOUD) .build(); ApiClient.init(apiConfiguration); Log.d(TAG, "onCreate end"); }
@Override public void onCreate() { super.onCreate(); refWatcher = LeakCanary.install(this); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() // or .detectAll() for all detectable problems .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .penaltyDeath() .build()); // If using Android-Universal-Image-Loader // Create global configuration and initialize ImageLoader with default config // ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build(); // ImageLoader.getInstance().init(config); } }
@Override public void onCreate() { super.onCreate(); AppCompatDelegate.setDefaultNightMode(Preferences.Theme.getAutoDayNightMode(this)); AlgoliaClient.sSortByTime = Preferences.isSortByRecent(this); mRefWatcher = LeakCanary.install(this); if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyFlashScreen() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .build()); } Preferences.migrate(this); TYPE_FACE = FontCache.getInstance().get(this, Preferences.Theme.getTypeface(this)); AppUtils.registerAccountsUpdatedListener(this); AdBlocker.init(this, Schedulers.io()); }
@Override protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GetOrComputeYearClass findYearClass = new GetOrComputeYearClass(); findYearClass.execute(); mYearClass = (TextView) findViewById(R.id.year_class); }
@Override public void onCreate() { super.onCreate(); Stetho.initializeWithDefaults(this); if (BuildConfig.DEBUG) { StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); } JobManager.create(this).addJobCreator(new DemoJobCreator()); } }
.detectAll() .penaltyLog() .build());
public void setHostname(String hostname, int port){ mHostname = hostname; mPort = port; mType = Type.REMOTE; try{ // This is needed to avoid NetworkOnMainThreadException StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); mAddress = InetAddress.getByName(mHostname); } catch(Exception e){ Logger.debug(e.toString()); } }
@Override public void onCreate() { super.onCreate(); setThreadPolicy(new ThreadPolicy.Builder().detectAll().penaltyLog().build()); setVmPolicy(new VmPolicy.Builder().detectAll().penaltyLog().build()); } }
@Override public void run() { // why PMD suppression is needed: https://github.com/pmd/pmd/issues/808 android.os.Process.setThreadPriority(DEFAULT_PRIORITY); //NOPMD AccessorMethodGeneration if (preventNetworkOperations) { StrictMode.setThreadPolicy( new ThreadPolicy.Builder() .detectNetwork() .penaltyDeath() .build()); } try { super.run(); } catch (Throwable t) { uncaughtThrowableStrategy.handle(t); } } };
private static void enabledStrictMode() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() // .detectAll() // .penaltyLog() // .penaltyDeath() // .build()); } }