Page Banner

How to enable strict mode debugging – Android Studio

StrictMode is a developer tool which can be used to detects errors that are very hard to identify. Generally it detects things you might be doing by accident.

StrictMode is a handy way to catch accidental disk or network access on the application’s main thread. You can make much smoother/responsive UI, prevent ANR dialogs from being shown to users by keeping disk and network operations off the main thread. To enable strict mode just place the following code inside onCreate() method of your activity.

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectNetwork()   // or .detectAll() for all detectable problems
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()