Sdílet prostřednictvím


Instrumentation Class

Definition

Base class for implementing application instrumentation code.

[Android.Runtime.Register("android/app/Instrumentation", DoNotGenerateAcw=true)]
public class Instrumentation : Java.Lang.Object
[<Android.Runtime.Register("android/app/Instrumentation", DoNotGenerateAcw=true)>]
type Instrumentation = class
    inherit Object
Inheritance
Instrumentation
Derived
Attributes

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 &lt;instrumentation&gt; tag.

Java documentation for android.app.Instrumentation.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Instrumentation()
Instrumentation(IntPtr, JniHandleOwnership)

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

Fields

ReportKeyIdentifier

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the class that is writing the report.

ReportKeyStreamresult

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.

Properties

AllocCounts

Returns a bundle with the current results from the allocation counting.

BinderCounts

Returns a bundle with the counts for various binder counts for this process.

Class

Returns the runtime class of this Object.

(Inherited from Object)
ComponentName

Returns complete component name of this instrumentation.

Context

Return the Context of this instrumentation's package.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsProfiling

Check whether this instrumentation was started with profiling enabled.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ProcessName

Return the name of the process this instrumentation is running in.

TargetContext

Return a Context for the target application being instrumented.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

UiAutomation

Gets the UiAutomation instance with no flags set.

Methods

AcquireLooperManager(Looper)

Takes control of the execution of messages on the specified looper until TestLooperManager#release is called.

AddMonitor(Instrumentation+ActivityMonitor)

Add a new ActivityMonitor that will be checked whenever an activity is started.

AddMonitor(IntentFilter, Instrumentation+ActivityResult, Boolean)

Add a new ActivityMonitor that will be checked whenever an activity is started.

AddMonitor(String, Instrumentation+ActivityResult, Boolean)

Add a new ActivityMonitor that will be checked whenever an activity is started.

AddResults(Bundle)

Report some results in the middle of instrumentation execution.

CallActivityOnCreate(Activity, Bundle, PersistableBundle)

Perform calling of an activity's Activity#onCreate method.

CallActivityOnCreate(Activity, Bundle)

Perform calling of an activity's Activity#onCreate method.

CallActivityOnDestroy(Activity)
CallActivityOnNewIntent(Activity, Intent)

Perform calling of an activity's Activity#onNewIntent method.

CallActivityOnPause(Activity)

Perform calling of an activity's Activity#onPause method.

CallActivityOnPictureInPictureRequested(Activity)

Perform calling of an activity's Activity#onPictureInPictureRequested method.

CallActivityOnPostCreate(Activity, Bundle, PersistableBundle)

Perform calling of an activity's Activity#onPostCreate method.

CallActivityOnPostCreate(Activity, Bundle)

Perform calling of an activity's Activity#onPostCreate method.

CallActivityOnRestart(Activity)

Perform calling of an activity's Activity#onRestart method.

CallActivityOnRestoreInstanceState(Activity, Bundle, PersistableBundle)

Perform calling of an activity's Activity#onRestoreInstanceState method.

CallActivityOnRestoreInstanceState(Activity, Bundle)

Perform calling of an activity's Activity#onRestoreInstanceState method.

CallActivityOnResume(Activity)

Perform calling of an activity's Activity#onResume method.

CallActivityOnSaveInstanceState(Activity, Bundle, PersistableBundle)

Perform calling of an activity's Activity#onSaveInstanceState method.

CallActivityOnSaveInstanceState(Activity, Bundle)

Perform calling of an activity's Activity#onSaveInstanceState 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)

Test whether an existing ActivityMonitor has been hit.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
EndPerformanceSnapshot()
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Finish(Result, Bundle)

Terminate instrumentation of the application.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetUiAutomation(UiAutomationFlags)

Gets the UiAutomation instance with flags set.

InvokeContextMenuAction(Activity, Int32, MenuPerformFlags)

Show the context menu for the currently focused view and executes a particular context menu item.

InvokeMenuActionSync(Activity, Int32, MenuPerformFlags)

Execute a particular menu item.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, ICharSequence, Activity, String, Object)

Perform instantiation of an Activity object.

NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, String, Activity, String, Object)

Perform instantiation of an Activity object.

NewActivity(ClassLoader, String, Intent)

Perform instantiation of the process's Activity object.

NewApplication(Class, Context)

Perform instantiation of the process's Application object.

NewApplication(ClassLoader, String, Context)

Perform instantiation of the process's Application object.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from 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)

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 ActivityMonitor that was previously added with #addMonitor.

ResetInTouchMode()

Resets the #setInTouchMode touch mode to the device default.

RunOnMainSync(Action)
RunOnMainSync(IRunnable)

Execute a call on the application's main thread, blocking until it is complete.

SendCharacterSync(Keycode)

Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.

SendKeyDownUpSync(Keycode)

Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.

SendKeySync(KeyEvent)

Sends a key event to the currently focused window, and waits for it to be processed.

SendPointerSync(MotionEvent)

Dispatches a pointer event into a window owned by the instrumented application, and waits for it to be processed.

SendStatus(Result, Bundle)

Provide a status report about the application.

SendStringSync(String)

Sends the key events that result in the given text being typed into the currently focused window, and waits for it to be processed.

SendTrackballEventSync(MotionEvent)

Dispatches a trackball event into the currently focused window, and waits for it to be processed.

SetAutomaticPerformanceSnapshots()
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
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, Bundle)

Start a new activity and wait for it to begin running before returning.

StartActivitySync(Intent)

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.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WaitForIdle(Action)
WaitForIdle(IRunnable)

Schedule a callback for when the application's main thread goes idle (has no more events to process).

WaitForIdleSync()

Synchronously wait for the application to be idle.

WaitForMonitor(Instrumentation+ActivityMonitor)

Wait for an existing ActivityMonitor to be hit.

WaitForMonitorWithTimeout(Instrumentation+ActivityMonitor, Int64)

Wait for an existing ActivityMonitor to be hit till the timeout expires.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to