Android Guides | Samples

Java.Lang.Object.GetObject<T> Method

Wraps a JNI object reference into a fully typed IJavaObject implementation.

Syntax

public static T GetObject<T> (IntPtr handle, JniHandleOwnership transfer)
where T : class, IJavaObject

Type Parameters

T
The type of the object to return. This type must be a reference type and implement the IJavaObject interface.

Parameters

handle
A IntPtr containing a Java Native Interface (JNI) object reference.
transfer

Returns

A T instance which references that Android object instance handle.

Exceptions

TypeReason
InvalidCastExceptionhandle is not of the appropriate type, as determied by JNIEnv.IsInstanceOf.

Remarks

Use this method to easily obtain a reference around a pre-existing Java Native Interface object reference.

Requirements

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