StrictMode.ThreadPolicy.Builder
public
static
final
class
StrictMode.ThreadPolicy.Builder
extends Object
| java.lang.Object | |
| ↳ | android.os.StrictMode.ThreadPolicy.Builder |
Creates 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);
Summary
Public constructors | |
|---|---|
StrictMode.ThreadPolicy.Builder()
Create a Builder that detects nothing and has no violations. |
|
StrictMode.ThreadPolicy.Builder(StrictMode.ThreadPolicy policy)
Initialize a Builder from an existing ThreadPolicy. |
|
Public methods | |
|---|---|
StrictMode.ThreadPolicy
|
build()
Construct the ThreadPolicy instance. |
StrictMode.ThreadPolicy.Builder
|
detectAll()
Detect everything that's potentially suspect. |
StrictMode.ThreadPolicy.Builder
|
detectCustomSlowCalls()
Enable detection of slow calls. |
StrictMode.ThreadPolicy.Builder
|
detectDiskReads()
Enable detection of disk reads. |
StrictMode.ThreadPolicy.Builder
|
detectDiskWrites()
Enable detection of disk writes. |
StrictMode.ThreadPolicy.Builder
|
detectNetwork()
Enable detection of network operations. |
StrictMode.ThreadPolicy.Builder
|
detectResourceMismatches()
Enables detection of mismatches between defined resource types and getter calls. |
StrictMode.ThreadPolicy.Builder
|
detectUnbufferedIo()
Detect unbuffered input/output operations. |
StrictMode.ThreadPolicy.Builder
|
penaltyDeath()
Crash the whole process on violation. |
StrictMode.ThreadPolicy.Builder
|
penaltyDeathOnNetwork()
Crash the whole process on any network usage. |
StrictMode.ThreadPolicy.Builder
|
penaltyDialog()
Show an annoying dialog to the developer on detected violations, rate-limited to be only a little annoying. |
StrictMode.ThreadPolicy.Builder
|
penaltyDropBox()
Enable detected violations log a stacktrace and timing data
to the |
StrictMode.ThreadPolicy.Builder
|
penaltyFlashScreen()
Flash the screen during a violation. |
StrictMode.ThreadPolicy.Builder
|
penaltyLog()
Log detected violations to the system log. |
StrictMode.ThreadPolicy.Builder
|
permitAll()
Disable the detection of everything. |
StrictMode.ThreadPolicy.Builder
|
permitCustomSlowCalls()
Disable detection of slow calls. |
StrictMode.ThreadPolicy.Builder
|
permitDiskReads()
Disable detection of disk reads. |
StrictMode.ThreadPolicy.Builder
|
permitDiskWrites()
Disable detection of disk writes. |
StrictMode.ThreadPolicy.Builder
|
permitNetwork()
Disable detection of network operations. |
StrictMode.ThreadPolicy.Builder
|
permitResourceMismatches()
Disable detection of mismatches between defined resource types and getter calls. |
StrictMode.ThreadPolicy.Builder
|
permitUnbufferedIo()
Disable detection of unbuffered input/output operations. |
Inherited methods | |
|---|---|
java.lang.Object
| |
Public constructors
StrictMode.ThreadPolicy.Builder
StrictMode.ThreadPolicy.Builder ()
Create a Builder that detects nothing and has no
violations. (but note that build() will default
to enabling penaltyLog() if no other penalties
are specified)
StrictMode.ThreadPolicy.Builder
StrictMode.ThreadPolicy.Builder (StrictMode.ThreadPolicy policy)
Initialize a Builder from an existing ThreadPolicy.
| Parameters | |
|---|---|
policy |
StrictMode.ThreadPolicy |
Public methods
build
StrictMode.ThreadPolicy build ()
Construct the ThreadPolicy instance.
Note: if no penalties are enabled before calling
build, penaltyLog() is implicitly
set.
| Returns | |
|---|---|
StrictMode.ThreadPolicy |
|
detectAll
StrictMode.ThreadPolicy.Builder detectAll ()
Detect everything that's potentially suspect.
As of the Gingerbread release this includes network and disk operations but will likely expand in future releases.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectCustomSlowCalls
StrictMode.ThreadPolicy.Builder detectCustomSlowCalls ()
Enable detection of slow calls.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectDiskReads
StrictMode.ThreadPolicy.Builder detectDiskReads ()
Enable detection of disk reads.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectDiskWrites
StrictMode.ThreadPolicy.Builder detectDiskWrites ()
Enable detection of disk writes.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectNetwork
StrictMode.ThreadPolicy.Builder detectNetwork ()
Enable detection of network operations.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectResourceMismatches
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 getInt(int, int)
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.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
detectUnbufferedIo
StrictMode.ThreadPolicy.Builder detectUnbufferedIo ()
Detect unbuffered input/output operations.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyDeath
StrictMode.ThreadPolicy.Builder penaltyDeath ()
Crash 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(), this applies
to disk reads, disk writes, and network usage if their
corresponding detect flags are set.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyDeathOnNetwork
StrictMode.ThreadPolicy.Builder penaltyDeathOnNetwork ()
Crash the whole process on any network usage. Unlike
penaltyDeath(), this penalty runs
before anything else. You must still have
called detectNetwork() to enable this.
In the Honeycomb or later SDKs, this is on by default.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyDialog
StrictMode.ThreadPolicy.Builder penaltyDialog ()
Show an annoying dialog to the developer on detected violations, rate-limited to be only a little annoying.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyDropBox
StrictMode.ThreadPolicy.Builder penaltyDropBox ()
Enable detected violations log a stacktrace and timing data
to the DropBox on policy
violation. Intended mostly for platform integrators doing
beta user field data collection.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyFlashScreen
StrictMode.ThreadPolicy.Builder penaltyFlashScreen ()
Flash the screen during a violation.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
penaltyLog
StrictMode.ThreadPolicy.Builder penaltyLog ()
Log detected violations to the system log.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitAll
StrictMode.ThreadPolicy.Builder permitAll ()
Disable the detection of everything.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitCustomSlowCalls
StrictMode.ThreadPolicy.Builder permitCustomSlowCalls ()
Disable detection of slow calls.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitDiskReads
StrictMode.ThreadPolicy.Builder permitDiskReads ()
Disable detection of disk reads.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitDiskWrites
StrictMode.ThreadPolicy.Builder permitDiskWrites ()
Disable detection of disk writes.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitNetwork
StrictMode.ThreadPolicy.Builder permitNetwork ()
Disable detection of network operations.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitResourceMismatches
StrictMode.ThreadPolicy.Builder permitResourceMismatches ()
Disable detection of mismatches between defined resource types and getter calls.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
permitUnbufferedIo
StrictMode.ThreadPolicy.Builder permitUnbufferedIo ()
Disable detection of unbuffered input/output operations.
| Returns | |
|---|---|
StrictMode.ThreadPolicy.Builder |
|
Interfaces
Classes
- AsyncTask
- BaseBundle
- BatteryManager
- Binder
- Build
- Build.VERSION
- Build.VERSION_CODES
- Bundle
- CancellationSignal
- ConditionVariable
- CountDownTimer
- CpuUsageInfo
- Debug
- Debug.InstructionCount
- Debug.MemoryInfo
- DropBoxManager
- DropBoxManager.Entry
- Environment
- FileObserver
- Handler
- HandlerThread
- HardwarePropertiesManager
- LocaleList
- Looper
- MemoryFile
- Message
- MessageQueue
- Messenger
- Parcel
- ParcelFileDescriptor
- ParcelFileDescriptor.AutoCloseInputStream
- ParcelFileDescriptor.AutoCloseOutputStream
- ParcelUuid
- PatternMatcher
- PersistableBundle
- PowerManager
- PowerManager.WakeLock
- Process
- ProxyFileDescriptorCallback
- RecoverySystem
- RemoteCallbackList
- ResultReceiver
- StatFs
- StrictMode
- StrictMode.ThreadPolicy
- StrictMode.ThreadPolicy.Builder
- StrictMode.VmPolicy
- StrictMode.VmPolicy.Builder
- SystemClock
- TestLooperManager
- TokenWatcher
- Trace
- UserHandle
- UserManager
- VibrationEffect
- Vibrator
- WorkSource
Enums
Exceptions