Android Guides | Samples

Android.App.Instrumentation Class

Base class for implementing application instrumentation code.

See Also: Instrumentation

Syntax

[Android.Runtime.Register("android/app/Instrumentation", DoNotGenerateAcw=true)]
public class Instrumentation : Object

Remarks

Base class for implementing application instrumentation code. When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml's <instrumentation> tag.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.App.Instrumentation are listed below.

See Also: Object

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
ReportKeyIdentifierString. If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the class that is writing the report.
const
ReportKeyStreamresultString. If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies a string which can simply be printed to the output stream.

Public Properties

[read-only]
AllocCountsBundle. Returns a bundle with the current results from the allocation counting.
[read-only]
BinderCountsBundle. Returns a bundle with the counts for various binder counts for this process.
[read-only]
ComponentNameComponentName. Returns complete component name of this instrumentation.
[read-only]
ContextContext. Return the Context of this instrumentation's package.
[read-only]
IsProfilingBoolean. Check whether this instrumentation was started with profiling enabled.
[read-only]
TargetContextContext. Return a Context for the target application being instrumented.
[read-only]
UiAutomationUiAutomation. Gets the UiAutomation instance.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddMonitor(Instrumentation+ActivityMonitor)
Add a new Instrumentation+ActivityMonitor that will be checked whenever an activity is started.
AddMonitor(IntentFilter, Instrumentation+ActivityResult, Boolean) : Instrumentation+ActivityMonitor
A convenience wrapper for Instrumentation.AddMonitor(.ActivityMonitor) that creates an intent filter matching Instrumentation+ActivityMonitor for you and returns it.
AddMonitor(String, Instrumentation+ActivityResult, Boolean) : Instrumentation+ActivityMonitor
A convenience wrapper for Instrumentation.AddMonitor(.ActivityMonitor) that creates a class matching Instrumentation+ActivityMonitor for you and returns it.
CallActivityOnCreate(Activity, Bundle)
Perform calling of an activity's Activity.OnCreate(Bundle) method.
CallActivityOnCreate(Activity, Bundle, PersistableBundle)
Perform calling of an activity's Activity.OnCreate(Bundle) method.
CallActivityOnDestroy(Activity)
CallActivityOnNewIntent(Activity, Intent)
Perform calling of an activity's Activity.OnNewIntent(Intent) method.
CallActivityOnPause(Activity)
Perform calling of an activity's Activity.OnPause method.
CallActivityOnPostCreate(Activity, Bundle)
Perform calling of an activity's Activity.OnPostCreate(Bundle) method.
CallActivityOnPostCreate(Activity, Bundle, PersistableBundle)
Perform calling of an activity's Activity.OnPostCreate(Bundle) method.
CallActivityOnRestart(Activity)
Perform calling of an activity's Activity.OnRestart method.
CallActivityOnRestoreInstanceState(Activity, Bundle)
Perform calling of an activity's Activity.OnRestoreInstanceState(Bundle) method.
CallActivityOnRestoreInstanceState(Activity, Bundle, PersistableBundle)
Perform calling of an activity's Activity.OnRestoreInstanceState(Bundle) method.
CallActivityOnResume(Activity)
Perform calling of an activity's Activity.OnResume method.
CallActivityOnSaveInstanceState(Activity, Bundle)
Perform calling of an activity's Activity.OnSaveInstanceState(Bundle) method.
CallActivityOnSaveInstanceState(Activity, Bundle, PersistableBundle)
Perform calling of an activity's Activity.OnSaveInstanceState(Bundle) method.
CallActivityOnStart(Activity)
Perform calling of an activity's Activity.OnStart method.
CallActivityOnStop(Activity)
Perform calling of an activity's Activity.OnStop method.
CallActivityOnUserLeaving(Activity)
Perform calling of an activity's Activity.OnUserLeaveHint method.
CallApplicationOnCreate(Application)
Perform calling of the application's Application.OnCreate method.
CheckMonitorHit(Instrumentation+ActivityMonitor, Int32) : Boolean
Test whether an existing Instrumentation+ActivityMonitor has been hit.
EndPerformanceSnapshot()
Finish(Result, Bundle)
Terminate instrumentation of the application.
InvokeContextMenuAction(Activity, Int32, MenuPerformFlags) : Boolean
Show the context menu for the currently focused view and executes a particular context menu item.
InvokeMenuActionSync(Activity, Int32, MenuPerformFlags) : Boolean
Execute a particular menu item.
NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, ICharSequence, Activity, String, Object) : Activity
NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, String, Activity, String, Object) : Activity
NewActivity(ClassLoader, String, Intent) : Activity
Perform instantiation of the process's Activity object.
static
NewApplication(Class, Context) : Application
Perform instantiation of the process's Application object.
NewApplication(ClassLoader, String, Context) : Application
Perform instantiation of the process's Application object.
OnCreate(Bundle)
Called when the instrumentation is starting, before any application code has been loaded.
OnDestroy()
Called when the instrumented application is stopping, after all of the normal application cleanup has occurred.
OnException(Object, Throwable) : Boolean
This is called whenever the system captures an unhandled exception that was thrown by the application.
OnStart()
Method where the instrumentation thread enters execution.
RemoveMonitor(Instrumentation+ActivityMonitor)
Remove an Instrumentation+ActivityMonitor that was previously added with Instrumentation.AddMonitor(.ActivityMonitor).
RunOnMainSync(IRunnable)
Execute a call on the application's main thread, blocking until it is complete.
RunOnMainSync(Action)
SendCharacterSync(Keycode)
Higher-level method for sending both the down and up key events for a particular character key code.
SendKeyDownUpSync(Keycode)
Sends an up and down key event sync to the currently focused window.
SendKeySync(KeyEvent)
Send a key event to the currently focused window/view and wait for it to be processed.
SendPointerSync(MotionEvent)
Dispatch a pointer event.
SendStatus(Result, Bundle)
Provide a status report about the application.
SendStringSync(String)
Sends the key events corresponding to the text to the app being instrumented.
SendTrackballEventSync(MotionEvent)
Dispatch a trackball event.
SetAutomaticPerformanceSnapshots()
SetInTouchMode(Boolean)
Force the global system in or out of touch mode.
Start()
Create and start a new thread in which to run instrumentation.
StartActivitySync(Intent) : Activity
Start a new activity and wait for it to begin running before returning.
StartAllocCounting()
StartPerformanceSnapshot()
StartProfiling()
This method will start profiling if isProfiling() returns true.
StopAllocCounting()
StopProfiling()
Stops profiling if isProfiling() returns true.
WaitForIdle(IRunnable)
Schedule a callback for when the application's main thread goes idle (has no more events to process).
WaitForIdle(Action)
WaitForIdleSync()
Synchronously wait for the application to be idle.
WaitForMonitor(Instrumentation+ActivityMonitor) : Activity
Wait for an existing Instrumentation+ActivityMonitor to be hit.
WaitForMonitorWithTimeout(Instrumentation+ActivityMonitor, Int64) : Activity
Wait for an existing Instrumentation+ActivityMonitor to be hit till the timeout expires.