public static class Instrumentation.ActivityMonitor extends Object
Instrumentation.addMonitor(android.app.Instrumentation.ActivityMonitor)
; after being added,
when a new activity is being started the monitor will be checked and, if
matching, its hit count updated and (optionally) the call stopped and a
canned result returned.
An ActivityMonitor can also be used to look for the creation of an
activity, through the waitForActivity()
method. This will return
after a matching activity has been created with that activity object.
Constructor and Description |
---|
ActivityMonitor(IntentFilter which,
Instrumentation.ActivityResult result,
boolean block)
Create a new ActivityMonitor that looks for a particular kind of
intent to be started.
|
ActivityMonitor(String cls,
Instrumentation.ActivityResult result,
boolean block)
Create a new ActivityMonitor that looks for a specific activity
class to be started.
|
Modifier and Type | Method and Description |
---|---|
IntentFilter |
getFilter()
Retrieve the filter associated with this ActivityMonitor.
|
int |
getHits()
Retrieve the number of times the monitor has been hit so far.
|
Activity |
getLastActivity()
Retrieve the most recent activity class that was seen by this
monitor.
|
Instrumentation.ActivityResult |
getResult()
Retrieve the result associated with this ActivityMonitor, or null if
none.
|
boolean |
isBlocking()
Check whether this monitor blocks activity starts (not allowing the
actual activity to run) or allows them to execute normally.
|
Activity |
waitForActivity()
Block until an Activity is created that matches this monitor,
returning the resulting activity.
|
Activity |
waitForActivityWithTimeout(long timeOut)
Block until an Activity is created that matches this monitor,
returning the resulting activity or till the timeOut period expires.
|
public ActivityMonitor(IntentFilter which, Instrumentation.ActivityResult result, boolean block)
which
- The set of intents this monitor is responsible for.result
- A canned result to return if the monitor is hit; can
be null.block
- Controls whether the monitor should block the activity
start (returning its canned result) or let the call
proceed.Instrumentation.addMonitor(android.app.Instrumentation.ActivityMonitor)
public ActivityMonitor(String cls, Instrumentation.ActivityResult result, boolean block)
cls
- The activity class this monitor is responsible for.result
- A canned result to return if the monitor is hit; can
be null.block
- Controls whether the monitor should block the activity
start (returning its canned result) or let the call
proceed.Instrumentation.addMonitor(android.app.Instrumentation.ActivityMonitor)
public final IntentFilter getFilter()
public final Instrumentation.ActivityResult getResult()
public final boolean isBlocking()
public final int getHits()
public final Activity getLastActivity()
public final Activity waitForActivity()
public final Activity waitForActivityWithTimeout(long timeOut)
timeOut
- Time to wait in milliseconds before the activity is created.