Created
July 28, 2014 19:18
-
-
Save billmote/296e9aaf9d535f8f5c97 to your computer and use it in GitHub Desktop.
Force StrictMode for developer builds without requiring tweaking of the phone/emulator settings.
This file contains hidden or 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
/** | |
* Created by Bill on 7/28/14. | |
*/ | |
public class LearningApplication extends Application { | |
private static final String TAG = QuickeyLearningApplication.class.getSimpleName(); | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
// If we're using a developer build on a phone > 2.3 then enforce StrictMode | |
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { | |
StrictMode.setThreadPolicy(buildPolicy()); | |
Log.w(TAG, "Strict Mode Enforced."); | |
} | |
} | |
private StrictMode.ThreadPolicy buildPolicy() { | |
return new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment