What is the ...
What is the ...
StrictMode is a developer tool in Android that helps detect and report certain types of application behavior that may be problematic. It is designed to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place[1][2][3].
When enabled, StrictMode can automatically terminate the app or log violations to logcat when certain conditions are met, such as:
By enabling StrictMode, developers can make their apps smoother and more responsive by keeping disk and network operations off the main thread[1][2][3]. This also helps prevent ANR (Application Not Responding) dialogs from being shown to users[2][3].
To enable StrictMode, you can add the following code in your Application
class's onCreate()
method (only for debug builds)[1][2][3]:
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penal...
senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào