Multiple choice

Which of the following is the correct way to declare StrictMode that detects all types of networks and disk I/O?

  1. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    .build());
    
  2. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDeath()
    .build());
    
  3. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyLog()
    .penaltyDialog()
    );
    
  4. StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .detectAll()
    .penaltyDialog()
    .build());
    
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Simple StrictMode declaration that detects all types of network and disk I/O:

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
 .detectAll()
 .penaltyLog()
 .penaltyDialog().build());