When I want to set strictMode in Application without handler - no effects in Activities.
This code is working:
public class MyApp extends Appliction {
@Override
public void onCreate() {
super.onCreate();
new android.os.Handler().post(new Runnable() {
@Override
public void run() {
setup_strict_mode();
}
});
}
}
This code is NOT working (no strict mode enabled in Activities)
public class MyApp extends Appliction {
@Override
public void onCreate() {
super.onCreate();
setup_strict_mode();
}
}
Here is setup_strict_mode:
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyDeath().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog().build());
Though onCreate is running in UI thead, so why this is happening?
Go to Settings > Developer options. Tap Advanced > Strict mode enabled.
StrictMode (android. os. StrictMode) class can be used to enable and enforce various policies that can be checked for and reported upon. This can be a StrictMode violation in executing a disk write violation that occurs when you are performing disk writes on the main UI thread.
Ok guys, I have found the solution. Its a bug described he
http://code.google.com/p/android/issues/detail?id=35298
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With