项目:GitHub
文件:WeatherApplication.java
@H_404_8@@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();
// Fabric.with(this,new Crashlytics());
Stetho.initializeWithDefaults(this.getApplicationContext());
weatherApplicationInstance = this;
//初始化apiclient
ApiConfiguration apiConfiguration = ApiConfiguration.builder()
.dataSourceType(ApiConstants.WEATHER_DATA_SOURCE_TYPE_KNow)
.build();
apiclient.init(apiConfiguration);
Log.d(TAG,"onCreate end");
}
项目:GitHub
文件:RuntimeCompat.java
@H_404_8@/**
* Determines the number of cores available on the device (pre-v17).
*
* <p>Before Jellybean,{@link Runtime#availableProcessors()} returned the number of awake cores,* which may not be the number of available cores depending on the device's current state. See
* https://stackoverflow.com/a/30150409.
*
* @return the maximum number of processors available to the VM; never smaller than one
*/
@SuppressWarnings("PMD")
private static int getCoreCountPre17() {
// We override the current ThreadPolicy to allow disk reads.
// This shouldn't actually do disk-IO and accesses a device file.
// See: https://github.com/bumptech/glide/issues/1170
File[] cpus = null;
ThreadPolicy originalPolicy = StrictMode.allowThreaddiskReads();
try {
File cpuInfo = new File(cpu_LOCATION);
final Pattern cpuNamePattern = Pattern.compile(cpu_NAME_REGEX);
cpus = cpuInfo.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file,String s) {
return cpuNamePattern.matcher(s).matches();
}
});
} catch (Throwable t) {
if (Log.isLoggable(TAG,Log.ERROR)) {
Log.e(TAG,"Failed to calculate accurate cpu count",t);
}
} finally {
StrictMode.setThreadPolicy(originalPolicy);
}
return Math.max(1,cpus != null ? cpus.length : 0);
}
项目:GitHub
文件:GlideExecutor.java
@H_404_8@@Override
public synchronized Thread newThread(@NonNull Runnable runnable) {
final Thread result = new Thread(runnable,"glide-" + name + "-thread-" + threadNum) {
@Override
public void run() {
android.os.Process.setThreadPriority(DEFAULT_PRIORITY);
if (preventNetworkOperations) {
StrictMode.setThreadPolicy(
new ThreadPolicy.Builder()
.detectNetwork()
.penaltyDeath()
.build());
}
try {
super.run();
} catch (Throwable t) {
uncaughtThrowableStrategy.handle(t);
}
}
};
threadNum++;
return result;
}
项目:Pluto-Android
文件:Utils.java
@H_404_8@/**
* 需要设置哪个页面的限制缓存到VM中
*/
@TargetApi(11)
public static void enableStrictMode(Class<?> clazz) {
if (Utils.hasgingerbread()) {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog();
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog();
if (Utils.hasHoneycomb()) {
threadPolicyBuilder.penaltyFlashScreen();
vmPolicyBuilder.setClassInstanceLimit(clazz,1);
}
StrictMode.setThreadPolicy(threadPolicyBuilder.build());
StrictMode.setVmPolicy(vmPolicyBuilder.build());
}
}
项目:MvpPlus
文件:StrictModeWrapper.java
@H_404_8@public static void init(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()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedsqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
}
}
项目:CurrentActivity
文件:CurrentActivity.java
@H_404_8@private void initStrictMode() {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder()
.detectdiskReads()
.detectdiskWrites()
.detectNetwork()
.detectCustomSlowCalls()
.penaltyDeath();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
threadPolicyBuilder.detectResourceMismatches();
}
StrictMode.setThreadPolicy(threadPolicyBuilder.build());
StrictMode.setVmPolicy(
new StrictMode.VmPolicy.Builder()
.detectLeakedsqlLiteObjects()
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.detectActivityLeaks()
.penaltyDeath()
.build()
);
}
项目:moppepojkar
文件:Settings.java
@H_404_8@protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.socket_connection_build);
ed_host = (EditText) findViewById(R.id.ed_host);
ed_port = (EditText) findViewById(R.id.ed_port);
btn_connect = (Button) findViewById(R.id.btn_connect);
/* Fetch earlier defined host ip and port numbers and write them as default
* (to avoid retyping this,typically standard,info) */
SharedPreferences mSharedPreferences = getSharedPreferences("list",MODE_PRIVATE);
String oldHost = mSharedPreferences.getString("host",null);
if (oldHost != null)
ed_host.setText(oldHost);
int oldPortCommunicator = mSharedPreferences.getInt("port",0);
if (oldPortCommunicator != 0)
ed_port.setText(Integer.toString(oldPortCommunicator));
}
项目:chromium-net-for-android
文件:PathUtils.java
@H_404_8@/**
* @return the public downloads directory.
*/
@SuppressWarnings("unused")
@CalledByNative
private static String getDownloadsDirectory(Context appContext) {
// Temporarily allowing disk access while fixing. Todo: http://crbug.com/508615
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
String downloadsPath;
try {
long time = SystemClock.elapsedRealtime();
downloadsPath = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS).getPath();
RecordHistogram.recordTimesHistogram("Android.StrictMode.DownloadsDir",SystemClock.elapsedRealtime() - time,TimeUnit.MILLISECONDS);
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
return downloadsPath;
}
项目:chromium-net-for-android
文件:EarlyTraceEvent.java
@H_404_8@/** @see TraceEvent#MaybeEnableEarlyTracing().
*/
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
static void maybeEnable() {
boolean shouldEnable = false;
// Checking for the trace config filename touches the disk.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
try {
if (CommandLine.isInitialized()
&& CommandLine.getInstance().hasSwitch("trace-startup")) {
shouldEnable = true;
} else {
try {
shouldEnable = (new File(TRACE_CONfig_FILENAME)).exists();
} catch (SecurityException e) {
// Access denied,not enabled.
}
}
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
if (shouldEnable) enable();
}
项目:chromium-net-for-android
文件:UploadDataProvidersTest.java
@H_404_8@@SuppressFBWarnings("DM_GC") // Used to trigger strictmode detecting leaked closeables
@Override
protected void tearDown() throws Exception {
try {
NativeTestServer.shutdownNativeTestServer();
mTestFramework.mcronetEngine.shutdown();
assertTrue(mFile.delete());
// Run GC and finalizers a few times to pick up leaked closeables
for (int i = 0; i < 10; i++) {
System.gc();
System.runFinalization();
}
System.gc();
System.runFinalization();
super.tearDown();
} finally {
StrictMode.setVmPolicy(mOldVmPolicy);
}
}
@H_404_8@public Thread newThread(final Runnable r) {
mNetworkQualityThread = new Thread(new Runnable() {
@Override
public void run() {
StrictMode.ThreadPolicy threadPolicy = StrictMode.getThreadPolicy();
try {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectNetwork()
.penaltyLog()
.penaltyDeath()
.build());
r.run();
} finally {
StrictMode.setThreadPolicy(threadPolicy);
}
}
});
return mNetworkQualityThread;
}
项目:javaide
文件:JecApp.java
@H_404_8@@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
if (startupTimestamp == 0)
startupTimestamp = System.currentTimeMillis();
if (SysUtils.isDebug(this))
{
L.debug = true;
//内存泄漏监控
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
builder.detectAll();
builder.penaltyLog();
StrictMode.setVmPolicy(builder.build());
}
installMonitor();
}
项目:GCSApp
文件:Utils.java
@H_404_8@@SuppressLint("NewApi")
public static void enableStrictMode() {
if (Utils.hasgingerbread()) {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog();
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog();
if (Utils.hasHoneycomb()) {
threadPolicyBuilder.penaltyFlashScreen();
vmPolicyBuilder
.setClassInstanceLimit(ImageGridActivity.class,1);
}
StrictMode.setThreadPolicy(threadPolicyBuilder.build());
StrictMode.setVmPolicy(vmPolicyBuilder.build());
}
}
项目:sekai
文件:AdUnitsSampleApplication.java
@H_404_8@@Override
public void onCreate() {
super.onCreate();
DebugSettings.initialize(this);
if (DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
}
项目:MDRXL
文件:SampleApplication.java
@H_404_8@@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(disK_THREAD_POLICY);
StrictMode.setVmPolicy(disK_VM_POLICY);
}
applicationComponent = DaggerApplicationComponent.builder()
.commonModule(new CommonModule(this))
.build();
for (final ProfilingProcessor processor : applicationComponent.profilingProcessors()) {
processor.enable();
}
}
项目:Dendroid-HTTP-RAT
文件:MyService.java
@H_404_8@public boolean isNetworkAvailable() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
return true;
// ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo netInfo = cm.getActiveNetworkInfo();
// if (netInfo != null && netInfo.isConnected()) {
// try {
// URL url = new URL("http://www.google.com");
// HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
// urlc.setConnectTimeout(3000);
// urlc.connect();
// if (urlc.getResponseCode() == 200) {
// return new Boolean(true);
// }
// } catch (MalformedURLException e1) {
// // Todo Auto-generated catch block
// e1.printstacktrace();
// } catch (IOException e) {
// // Todo Auto-generated catch block
// e.printstacktrace();
// }
// }
// return false;
}
项目:chromium-for-android-56-debug-video
文件:WebappActivity.java
@H_404_8@/**
* Saves the tab data out to a file.
*/
void saveState(File activityDirectory) {
String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(),false);
File tabFile = new File(activityDirectory,tabFileName);
// Temporarily allowing disk access while fixing. Todo: http://crbug.com/525781
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
StrictMode.allowThreaddiskWrites();
try {
long time = SystemClock.elapsedRealtime();
TabState.saveState(tabFile,getActivityTab().getState(),false);
RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappSaveState",TimeUnit.MILLISECONDS);
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}
@H_404_8@@TargetApi(VERSION_CODES.HONEYCOMB)
public static void enableStrictMode() {
if (Utils.hasgingerbread()) {
StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog();
StrictMode.VmPolicy.Builder vmPolicyBuilder =
new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog();
if (Utils.hasHoneycomb()) {
threadPolicyBuilder.penaltyFlashScreen();
vmPolicyBuilder
.setClassInstanceLimit(ImageGridActivity.class,1)
.setClassInstanceLimit(ImageDetailActivity.class,1);
}
StrictMode.setThreadPolicy(threadPolicyBuilder.build());
StrictMode.setVmPolicy(vmPolicyBuilder.build());
}
}
项目:chromium-for-android-56-debug-video
文件:WebappDirectoryManager.java
@H_404_8@/**
* Returns the directory for a web app,creating it if necessary.
* @param webappId ID for the web app. Used as a subdirectory name.
* @return File for storing @R_649_4045@ion about the web app.
*/
File getWebappDirectory(Context context,String webappId) {
// Temporarily allowing disk access while fixing. Todo: http://crbug.com/525781
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
StrictMode.allowThreaddiskWrites();
try {
long time = SystemClock.elapsedRealtime();
File webappDirectory = new File(getBaseWebappDirectory(context),webappId);
if (!webappDirectory.exists() && !webappDirectory.mkdir()) {
Log.e(TAG,"Failed to create web app directory.");
}
RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappDir",TimeUnit.MILLISECONDS);
return webappDirectory;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}
项目:chromium-for-android-56-debug-video
文件:BackgroundSyncLauncher.java
@H_404_8@private static boolean removeScheduledTasks(GcmNetworkManager scheduler) {
// Third-party code causes broadcast to touch disk. http://crbug.com/614679
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
try {
scheduler.cancelTask(TASK_TAG,ChromeBackgroundService.class);
} catch (IllegalArgumentException e) {
// This occurs when BackgroundSyncLauncherService is not found in the application
// manifest. This should not happen in code that reaches here,but has been seen in
// the past. See https://crbug.com/548314
// disable GCM for the remainder of this session.
setGcmenabled(false);
// Return false so that the failure will be logged.
return false;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
return true;
}
项目:chromium-for-android-56-debug-video
文件:FeatureUtilities.java
@H_404_8@/**
* @return Which flavor of Herb is being tested.
* See {@link ChromeSwitches#HERB_FLAVOR_ELDERBerry} and its related switches.
*/
public static String getHerbFlavor() {
Context context = ContextUtils.getApplicationContext();
if (isHerbdisallowed(context)) return ChromeSwitches.HERB_FLAVOR_disABLED;
if (!sIsHerbFlavorCached) {
sCachedHerbFlavor = null;
// Allowing disk access for preferences while prototyping.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreaddiskReads();
try {
sCachedHerbFlavor =
ChromePreferenceManager.getInstance(context).getCachedHerbFlavor();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
sIsHerbFlavorCached = true;
Log.d(TAG,"Retrieved cached Herb flavor: " + sCachedHerbFlavor);
}
return sCachedHerbFlavor;
}
项目:GitHub
文件:GlideExecutor.java
@H_404_8@/**
* Determines the number of cores available on the device.
*
* <p>{@link Runtime#availableProcessors()} returns the number of awake cores,which may not
* be the number of available cores depending on the device's current state. See
* http://goo.gl/8H670N.
*/
public static int calculateBestThreadCount() {
// We override the current ThreadPolicy to allow disk reads.
// This shouldn't actually do disk-IO and accesses a device file.
// See: https://github.com/bumptech/glide/issues/1170
ThreadPolicy originalPolicy = StrictMode.allowThreaddiskReads();
File[] cpus = null;
try {
File cpuInfo = new File(cpu_LOCATION);
final Pattern cpuNamePattern = Pattern.compile(cpu_NAME_REGEX);
cpus = cpuInfo.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file,t);
}
} finally {
StrictMode.setThreadPolicy(originalPolicy);
}
int cpuCount = cpus != null ? cpus.length : 0;
int availableProcessors = Math.max(1,Runtime.getRuntime().availableProcessors());
return Math.min(MAXIMUM_AUTOMATIC_THREAD_COUNT,Math.max(availableProcessors,cpuCount));
}
项目:Boilerplate
文件:TlApplication.java
项目:GitHub
文件:SampleApplication.java
@H_404_8@@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setStrictMode() {
if (Integer.valueOf(Build.VERSION.SDK) > 3) {
Log.d(LOG_TAG,"Enabling StrictMode policy over Sample application");
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
}
项目:KTools
文件:KApplication.java
@H_404_8@private void enableThreadPolicy() {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build()
);
}
项目:ImageLoaderSupportGif
文件:UILApplication.java
@H_404_8@@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressWarnings("unused")
@Override
public void onCreate() {
if (Constants.Config.DEVELOPER_MODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
}
super.onCreate();
initimageLoader(getApplicationContext());
}
项目:GitHub
文件:MockGlideExecutor.java
@H_404_8@@Override
public void execute(@NonNull final Runnable command) {
delegate.execute(new Runnable() {
@Override
public void run() {
StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
StrictMode.setThreadPolicy(THREAD_POLICY);
try {
command.run();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}
});
}
项目:GitHub
文件:UILApplication.java
@H_404_8@@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressWarnings("unused")
@Override
public void onCreate() {
if (Constants.Config.DEVELOPER_MODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
}
super.onCreate();
initimageLoader(getApplicationContext());
}
项目:subscriptions-leak-example
文件:App.java
@H_404_8@private void initStrictMode() {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
项目:smart-lens
文件:MyApplication.java
@H_404_8@@Override
public void onCreate() {
super.onCreate();
//Enable strict mode
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
//Init shetho
Stetho.initializeWithDefaults(this);
//Enable timber
Timber.plant(new Timber.DebugTree() {
@Override
protected String createStackElementTag(StackTraceElement element) {
return super.createStackElementTag(element)
+ ":" + element.getmethodName()
+ " ->L" + element.getLineNumber();
}
});
}
项目:AndroidAsyncHTTP
文件:SampleApplication.java
@H_404_8@@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void setStrictMode() {
if (Integer.valueOf(Build.VERSION.SDK) > 3) {
Log.d(LOG_TAG,"Enabling StrictMode policy over Sample application");
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
}
项目:firefox-tv
文件:Locales.java
@H_404_8@/**
* Is only required by locale aware activities,AND Application. In most cases you should be
* using LocaleAwareAppCompatActivity or friends.
* @param context
*/
public static void initializeLocale(Context context) {
final LocaleManager localeManager = LocaleManager.getInstance();
final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreaddiskReads();
StrictMode.allowThreaddiskWrites();
try {
localeManager.getAndApplyPersistedLocale(context);
} finally {
StrictMode.setThreadPolicy(savedPolicy);
}
}
项目:BadIntent
文件:TransactionHooks.java
@H_404_8@protected Thread sendParcel(ParcelContainer container,int code,int flags) throws IOException {
//Prevent from casting exceptions with respect to "Network Access on Main Thread"
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
String resource = "/parcel/" + container.getParcelID();
URL url = ConnectionUtils.getBadIntentURL(resource,sPrefs,port);
String jsonData = SerializationUtils.getJson(container,code,flags);
final HttpURLConnection conn = ConnectionUtils.getBadIntentHttpURLConnection(url,sPrefs);
conn.setRequestMethod("POST");
conn.setRequestProperty("__BadIntent__","Parcel");
conn.setRequestProperty("__BadIntent__.package",lpparam.packageName);
conn.setRequestProperty("Content-Type","application/json; charset=UTF-8");
conn.setRequestProperty("Accept","application/json");
conn.setDoOutput(true);
conn.connect();
DataOutputStream writer = new DataOutputStream(conn.getoutputStream());
writer.writeBytes(jsonData);
writer.flush();
writer.close();
//create new thread,which reads HTTP result
return ConnectionUtils.readResponseAndCloseConnection(conn);
}
项目:Nird2
文件:SplashScreenActivity.java
@H_404_8@private void enableStrictMode() {
if (TESTING) {
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
threadPolicy.detectAll();
threadPolicy.penaltyLog();
StrictMode.setThreadPolicy(threadPolicy.build());
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
vmPolicy.detectAll();
vmPolicy.penaltyLog();
StrictMode.setVmPolicy(vmPolicy.build());
}
}
项目:Acg
文件:DebugDemoApp.java
@H_404_8@private void init() {
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();
}
项目:SensorDataVisualizer
文件:MainActivity.java
@H_404_8@@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
StrictMode.setThreadPolicy(policy);
ActionBar ab = this.getActionBar();
// Enable the Up button
if (ab != null) {
ab.setdisplayHomeAsUpEnabled(true);
}
// Todo remove ugly test code :D
// Calendar calendar = Calendar.getInstance(Locale.GERMANY);
// calendar.set(2017,9,31);
// try {
// ParticluateMatters particluateMatters = new ParticluateMatters();
// particluateMatters.read(5837,calendar.getTime());
// calendar.add(Calendar.DAY_OF_YEAR,-1);
// particluateMatters.read(5837,calendar.getTime());
// System.out.println(particluateMatters.getMinValue() + " - " + particluateMatters.getMaxValue());
// } catch (Exception e) {
// e.printstacktrace();
// }
}
项目:MainCalendar
文件:MainApplication.java
@H_404_8@private void enabledStrictMode() {
if (SDK_INT >= GINGERBREAD) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。