Skip to content

Instantly share code, notes, and snippets.

@billmote
Created July 28, 2014 19:18
Show Gist options
  • Save billmote/296e9aaf9d535f8f5c97 to your computer and use it in GitHub Desktop.
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.
/**
* 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