Câu hỏi phỏng vấn Android
Câu hỏi

What is the ...

Câu trả lời

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:

  • Disk reads or writes on the main thread[1][2][3]
  • Network access on the main thread[2][3]
  • Leaked SQLite objects[2]
  • Leaked closable objects[2]

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]:

java Copy
if (BuildConfig.DEBUG) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
        .detectDiskReads()
        .detectDiskWrites()
        .detectNetwork()
        .penal...
senior

senior

Gợi ý câu hỏi phỏng vấn

senior

Discuss Singletons vs. Application Context for app-global state

senior

What is the Android NDK? How can one use it? Why should one use it?

junior

Explain Android notification system

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào