java.lang.Object | |
↳ | android.os.StrictMode.VmPolicy.Builder |
Creates
StrictMode.VmPolicy
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.VmPolicy policy = new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .build(); StrictMode.setVmPolicy(policy);
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||
|
Build upon an existing VmPolicy.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Construct the VmPolicy instance.
|
||||||||||
|
Detect leaks of
Activity
subclasses.
|
||||||||||
|
Detect everything that's potentially suspect.
|
||||||||||
|
Detect when a
file://
Uri
is exposed beyond this
app.
|
||||||||||
|
Detect when an
Closeable
or other
object with a explict termination method is finalized
without having been closed.
|
||||||||||
|
|
||||||||||
|
Detect when an
SQLiteCursor
or other
SQLite object is finalized without having been closed.
|
||||||||||
|
Crashes the whole process on violation.
|
||||||||||
|
Enable detected violations log a stacktrace and timing data
to the
DropBox
on policy
violation.
|
||||||||||
|
Log detected violations to the system log.
|
||||||||||
|
Set an upper bound on how many instances of a class can be in memory
at once.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Build upon an existing VmPolicy.
Construct the VmPolicy instance.
Note: if no penalties are enabled before calling
build
,
penaltyLog()
is implicitly
set.
Detect leaks of
Activity
subclasses.
Detect everything that's potentially suspect.
In the Honeycomb release this includes leaks of SQLite cursors, Activities, and other closable objects but will likely expand in future releases.
Detect when a
file://
Uri
is exposed beyond this
app. The receiving app may not have access to the sent path.
Instead, when sharing files between apps,
content://
should be used with permission grants.
Detect when an
Closeable
or other
object with a explict termination method is finalized
without having been closed.
You always want to explicitly close such objects to avoid unnecessary resources leaks.
Detect when a
BroadcastReceiver
or
ServiceConnection
is leaked during
Context
teardown.
Detect when an
SQLiteCursor
or other
SQLite object is finalized without having been closed.
You always want to explicitly close your SQLite cursors to avoid unnecessary database contention and temporary memory leaks.
Crashes the whole process on violation. This penalty runs at the end of all enabled penalties so yo you'll still get your logging or other violations before the process dies.
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.
Log detected violations to the system log.
Set an upper bound on how many instances of a class can be in memory at once. Helps to prevent object leaks.