Added in API level 1

Instrumentation.ActivityMonitor


public static class Instrumentation.ActivityMonitor
extends Object

java.lang.Object
   ↳ android.app.Instrumentation.ActivityMonitor


Information about a particular kind of Intent that is being monitored. An instance of this class is added to the current instrumentation through Instrumentation.addMonitor(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.

Summary

Public constructors

ActivityMonitor()

Create a new ActivityMonitor that can be used for intercepting any activity to be started.

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.

Public methods

final IntentFilter getFilter()

Retrieve the filter associated with this ActivityMonitor.

final int getHits()

Retrieve the number of times the monitor has been hit so far.

final Activity getLastActivity()

Retrieve the most recent activity class that was seen by this monitor.

final Instrumentation.ActivityResult getResult()

Retrieve the result associated with this ActivityMonitor, or null if none.

final boolean isBlocking()

Check whether this monitor blocks activity starts (not allowing the actual activity to run) or allows them to execute normally.

Instrumentation.ActivityResult onStartActivity(Intent intent)

Used for intercepting any started activity.

final Activity waitForActivity()

Block until an Activity is created that matches this monitor, returning the resulting activity.

final Activity