# StrictMode.ThreadPolicy.Builder

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#inhmethods)  

# StrictMode.ThreadPolicy.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/StrictMode.ThreadPolicy.Builder "View this page in Kotlin")\|Java

`
public
static
final

class
StrictMode.ThreadPolicy.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|--------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.StrictMode.ThreadPolicy.Builder |

<br />

*** ** * ** ***

Creates[ThreadPolicy](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy)instances. Methods whose names start with`detect`specify what problems we should look for. Methods whose names start with`penalty`specify what we should do when we detect a problem.

You can call as many`detect`and`penalty`methods as you like. Currently order is insignificant: all penalties apply to all detected problems.

For example, detect everything and log anything that's found:  

```
 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
     .detectAll()
     .penaltyLog()
     .build();
 StrictMode.setThreadPolicy(policy);
 
```

<br />

## Summary

|                                                                                                                                                 ### Public constructors                                                                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#Builder())`() ` Creates a Builder that detects nothing and has no violations.                                                                                                                                        |
| ` `[Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#Builder(android.os.StrictMode.ThreadPolicy))`(`[StrictMode.ThreadPolicy](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy)` policy) ` Initializes a Builder from an existing ThreadPolicy. |

|                                                                                                                                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[StrictMode.ThreadPolicy](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy)                 | ` `[build](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#build())`() ` Constructs the ThreadPolicy instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectAll](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectAll())`() ` Detects everything that's potentially suspect.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectCustomSlowCalls](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectCustomSlowCalls())`() ` Enables detection of slow calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectDiskReads](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectDiskReads())`() ` Enables detection of disk reads.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectDiskWrites](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectDiskWrites())`() ` Enables detection of disk writes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectExplicitGc](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectExplicitGc())`() ` Detects calls to[Runtime.gc()](https://developer.android.com/reference/java/lang/Runtime#gc()).                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectNetwork](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectNetwork())`() ` Enables detection of network operations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectResourceMismatches](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectResourceMismatches())`() ` Enables detection of mismatches between defined resource types and getter calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[detectUnbufferedIo](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectUnbufferedIo())`() ` Detects unbuffered input/output operations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyDeath](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDeath())`() ` Crashes the whole process on violation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyDeathOnNetwork](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDeathOnNetwork())`() ` Crashes the whole process on any network usage.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyDialog](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDialog())`() ` Shows an annoying dialog to the developer on detected violations, rate-limited to be only a little annoying.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyDropBox](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDropBox())`() ` Enables detected violations log a stacktrace and timing data to the[DropBox](https://developer.android.com/reference/android/os/DropBoxManager)on policy violation.                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyFlashScreen](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyFlashScreen())`() ` Flashes the screen during a violation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyListener](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyListener(java.util.concurrent.Executor,%20android.os.StrictMode.OnThreadViolationListener))`(`[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)` executor, `[StrictMode.OnThreadViolationListener](https://developer.android.com/reference/android/os/StrictMode.OnThreadViolationListener)` listener) ` Calls #[OnThreadViolationListener.onThreadViolation(Violation)](https://developer.android.com/reference/android/os/StrictMode.OnThreadViolationListener#onThreadViolation(android.os.strictmode.Violation))on specified executor every violation. |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[penaltyLog](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyLog())`() ` Logs detected violations to the system log.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitAll](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitAll())`() ` Disables the detection of everything.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitCustomSlowCalls](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitCustomSlowCalls())`() ` Disables detection of slow calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitDiskReads](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitDiskReads())`() ` Disables detection of disk reads.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitDiskWrites](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitDiskWrites())`() ` Disables detection of disk writes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitExplicitGc](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitExplicitGc())`() ` Disables detection of calls to[Runtime.gc()](https://developer.android.com/reference/java/lang/Runtime#gc()).                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitNetwork](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitNetwork())`() ` Disables detection of network operations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitResourceMismatches](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitResourceMismatches())`() ` Disables detection of mismatches between defined resource types and getter calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | ` `[permitUnbufferedIo](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#permitUnbufferedIo())`() ` Disables detection of unbuffered input/output operations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder ()
```

Creates a Builder that detects nothing and has no violations. (but note that[build()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#build())will default to enabling[penaltyLog()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyLog())if no other penalties are specified)

<br />

### Builder

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (StrictMode.ThreadPolicy policy)
```

Initializes a Builder from an existing ThreadPolicy.

<br />

|                 Parameters                 ||
|----------|----------------------------------|
| `policy` | `StrictMode.ThreadPolicy` <br /> |

## Public methods

### build

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy build ()
```

Constructs the ThreadPolicy instance.

Note: if no penalties are enabled before calling`build`,[penaltyLog()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyLog())is implicitly set.

<br />

|                                                    Returns                                                    ||
|-------------------------------------------------------------------------------------------------------|--------|
| [StrictMode.ThreadPolicy](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy) | <br /> |

### detectAll

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectAll ()
```

Detects everything that's potentially suspect.

As of the Gingerbread release this includes network and disk operations but will likely expand in future releases.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectCustomSlowCalls

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectCustomSlowCalls ()
```

Enables detection of slow calls.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectDiskReads

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectDiskReads ()
```

Enables detection of disk reads.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectDiskWrites

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectDiskWrites ()
```

Enables detection of disk writes.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectExplicitGc

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectExplicitGc ()
```

Detects calls to[Runtime.gc()](https://developer.android.com/reference/java/lang/Runtime#gc()).

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectNetwork

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectNetwork ()
```

Enables detection of network operations.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectResourceMismatches

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectResourceMismatches ()
```

Enables detection of mismatches between defined resource types and getter calls.

This helps detect accidental type mismatches and potentially expensive type conversions when obtaining typed resources.

For example, a strict mode violation would be thrown when calling[TypedArray.getInt(int, int)](https://developer.android.com/reference/android/content/res/TypedArray#getInt(int,%20int))on an index that contains a String-type resource. If the string value can be parsed as an integer, this method call will return a value without crashing; however, the developer should format the resource as an integer to avoid unnecessary type conversion.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### detectUnbufferedIo

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder detectUnbufferedIo ()
```

Detects unbuffered input/output operations.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyDeath

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyDeath ()
```

Crashes the whole process on violation. This penalty runs at the end of all enabled penalties so you'll still get see logging or other violations before the process dies.

Unlike[penaltyDeathOnNetwork()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDeathOnNetwork()), this applies to disk reads, disk writes, and network usage if their corresponding detect flags are set.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyDeathOnNetwork

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyDeathOnNetwork ()
```

Crashes the whole process on any network usage. Unlike[penaltyDeath()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#penaltyDeath()), this penalty runs*before* anything else. You must still have called[detectNetwork()](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder#detectNetwork())to enable this.

In the Honeycomb or later SDKs, this is on by default.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyDialog

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyDialog ()
```

Shows an annoying dialog to the developer on detected violations, rate-limited to be only a little annoying.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyDropBox

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyDropBox ()
```

Enables detected violations log a stacktrace and timing data to the[DropBox](https://developer.android.com/reference/android/os/DropBoxManager)on policy violation. Intended mostly for platform integrators doing beta user field data collection.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyFlashScreen

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyFlashScreen ()
```

Flashes the screen during a violation.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyListener

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyListener (Executor executor, 
                StrictMode.OnThreadViolationListener listener)
```

Calls #[OnThreadViolationListener.onThreadViolation(Violation)](https://developer.android.com/reference/android/os/StrictMode.OnThreadViolationListener#onThreadViolation(android.os.strictmode.Violation))on specified executor every violation.

<br />

|                                       Parameters                                       ||
|------------|----------------------------------------------------------------------------|
| `executor` | `Executor`: This value cannot be`null`. <br />                             |
| `listener` | `StrictMode.OnThreadViolationListener`: This value cannot be`null`. <br /> |

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### penaltyLog

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder penaltyLog ()
```

Logs detected violations to the system log.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitAll

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitAll ()
```

Disables the detection of everything.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitCustomSlowCalls

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitCustomSlowCalls ()
```

Disables detection of slow calls.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitDiskReads

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitDiskReads ()
```

Disables detection of disk reads.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitDiskWrites

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitDiskWrites ()
```

Disables detection of disk writes.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitExplicitGc

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitExplicitGc ()
```

Disables detection of calls to[Runtime.gc()](https://developer.android.com/reference/java/lang/Runtime#gc()).

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitNetwork

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitNetwork ()
```

Disables detection of network operations.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitResourceMismatches

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitResourceMismatches ()
```

Disables detection of mismatches between defined resource types and getter calls.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |

### permitUnbufferedIo

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public StrictMode.ThreadPolicy.Builder permitUnbufferedIo ()
```

Disables detection of unbuffered input/output operations.

<br />

|                                                                          Returns                                                                          ||
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [StrictMode.ThreadPolicy.Builder](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) | This value cannot be`null`. <br /> |