Not many of you may have heard about Strict Mode in Android. Added in Api Level 9, it is a developer tool which detects those part of codes that may crash due to some voilations, and brings them to your attention with an error code that is easy to understand.
The Strict mode can help you detect various voilations such as :
Catch all accidental disk operations taking place on the main thread.
Catch all kind of network operations that are taking place in the main thread.
Detect all kind of leaked objects such as sql, cursors and much more.
StrictMode is most commonly used to catch accidental disk or network access on the application’s main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications.
Enabling strict mode is just a piece of cake. Just few lines of code in your application class, and its over.
- NOTE : Strict Mode should only be used in DEBUG mode.