Last active
November 7, 2018 17:16
-
-
Save CyxouD/aafb01d7b5b81022664bf0e9c9a04251 to your computer and use it in GitHub Desktop.
enable strict mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApplication extends Application { | |
private static final String TAG = "MyApplication"; | |
@Override | |
public void onCreate() { | |
if (BuildConfig.DEBUG) { | |
Log.w(TAG, "======================================================"); | |
Log.w(TAG, "======= APPLICATION IN STRICT MODE - DEBUGGING ======="); | |
Log.w(TAG, "======================================================"); | |
/** | |
* Doesn't enable anything on the main thread that related | |
* to resource access. | |
*/ | |
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() | |
.detectAll() | |
.penaltyLog() | |
.penaltyFlashScreen() | |
.penaltyDeath() | |
.build()); | |
/** | |
* Doesn't enable any leakage of the application's components. | |
*/ | |
final StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | |
builder.detectLeakedRegistrationObjects(); | |
} | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { | |
builder.detectFileUriExposure(); | |
} | |
builder.detectLeakedClosableObjects() | |
.detectLeakedSqlLiteObjects() | |
.penaltyLog() | |
.penaltyDeath(); | |
StrictMode.setVmPolicy(builder.build()); | |
} | |
super.onCreate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment