Legacy Documentation: Version 5.3
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AndroidJNI

class in UnityEngine

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

'Raw' JNI interface to Android Dalvik (Java) VM from Mono (CS/JS).

Static Functions

AllocObjectAllocates a new Java object without invoking any of the constructors for the object.
AttachCurrentThreadAttaches the current thread to a Java (Dalvik) VM.
CallBooleanMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallByteMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallCharMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallDoubleMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallFloatMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallIntMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallLongMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallObjectMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallShortMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallStaticBooleanMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticByteMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticCharMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticDoubleMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticFloatMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticIntMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticLongMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticObjectMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticShortMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticStringMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStaticVoidMethodInvokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.
CallStringMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
CallVoidMethodCalls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.
DeleteGlobalRefDeletes the global reference pointed to by obj.
DeleteLocalRefDeletes the local reference pointed to by obj.
DetachCurrentThreadDetaches the current thread from a Java (Dalvik) VM.
EnsureLocalCapacityEnsures that at least a given number of local references can be created in the current thread.
ExceptionClearClears any exception that is currently being thrown.
ExceptionDescribePrints an exception and a backtrace of the stack to the logcat
ExceptionOccurredDetermines if an exception is being thrown.
FatalErrorRaises a fatal error and does not expect the VM to recover. This function does not return.
FindClassThis function loads a locally-defined class.
FromBooleanArrayConvert a Java array of boolean to a managed array of System.Boolean.
FromByteArrayConvert a Java array of byte to a managed array of System.Byte.
FromCharArrayConvert a Java array of char to a managed array of System.Char.
FromDoubleArrayConvert a Java array of double to a managed array of System.Double.
FromFloatArrayConvert a Java array of float to a managed array of System.Single.
FromIntArrayConvert a Java array of int to a managed array of System.Int32.
FromLongArrayConvert a Java array of long to a managed array of System.Int64.
FromObjectArrayConvert a Java array of java.lang.Object to a managed array of System.IntPtr, representing Java objects.
FromReflectedFieldConverts a java.lang.reflect.Field to a field ID.
FromReflectedMethodConverts a java.lang.reflect.Method or java.lang.reflect.Constructor object to a method ID.
FromShortArrayConvert a Java array of short to a managed array of System.Int16.
GetArrayLengthReturns the number of elements in the array.
GetBooleanArrayElementReturns the value of one element of a primitive array.
GetBooleanFieldThis function returns the value of an instance (nonstatic) field of an object.
GetByteArrayElementReturns the value of one element of a primitive array.
GetByteFieldThis function returns the value of an instance (nonstatic) field of an object.
GetCharArrayElementReturns the value of one element of a primitive array.
GetCharFieldThis function returns the value of an instance (nonstatic) field of an object.
GetDoubleArrayElementReturns the value of one element of a primitive array.
GetDoubleFieldThis function returns the value of an instance (nonstatic) field of an object.
GetFieldIDReturns the field ID for an instance (nonstatic) field of a class.
GetFloatArrayElementReturns the value of one element of a primitive array.
GetFloatFieldThis function returns the value of an instance (nonstatic) field of an object.
GetIntArrayElementReturns the value of one element of a primitive array.
GetIntFieldThis function returns the value of an instance (nonstatic) field of an object.
GetLongArrayElementReturns the value of one element of a primitive array.
GetLongFieldThis function returns the value of an instance (nonstatic) field of an object.
GetMethodIDReturns the method ID for an instance (nonstatic) method of a class or interface.
GetObjectArrayElementReturns an element of an Object array.
GetObjectClassReturns the class of an object.
GetObjectFieldThis function returns the value of an instance (nonstatic) field of an object.
GetShortArrayElementReturns the value of one element of a primitive array.
GetShortFieldThis function returns the value of an instance (nonstatic) field of an object.
GetStaticBooleanFieldThis function returns the value of a static field of an object.
GetStaticByteFieldThis function returns the value of a static field of an object.
GetStaticCharFieldThis function returns the value of a static field of an object.
GetStaticDoubleFieldThis function returns the value of a static field of an object.
GetStaticFieldIDReturns the field ID for a static field of a class.
GetStaticFloatFieldThis function returns the value of a static field of an object.
GetStaticIntFieldThis function returns the value of a static field of an object.
GetStaticLongFieldThis function returns the value of a static field of an object.
GetStaticMethodIDReturns the method ID for a static method of a class.
GetStaticObjectFieldThis function returns the value of a static field of an object.
GetStaticShortFieldThis function returns the value of a static field of an object.
GetStaticStringFieldThis function returns the value of a static field of an object.
GetStringFieldThis function returns the value of an instance (nonstatic) field of an object.
GetStringUTFCharsReturns a managed string object representing the string in modified UTF-8 encoding.
GetStringUTFLengthReturns the length in bytes of the modified UTF-8 representation of a string.
GetSuperclassIf clazz represents any class other than the class Object, then this function returns the object that represents the superclass of the class specified by clazz.
GetVersionReturns the version of the native method interface.
IsAssignableFromDetermines whether an object of clazz1 can be safely cast to clazz2.
IsInstanceOfTests whether an object is an instance of a class.
IsSameObjectTests whether two references refer to the same Java object.
NewBooleanArrayConstruct a new primitive array object.
NewByteArrayConstruct a new primitive array object.
NewCharArrayConstruct a new primitive array object.
NewDoubleArrayConstruct a new primitive array object.
NewFloatArrayConstruct a new primitive array object.
NewGlobalRefCreates a new global reference to the object referred to by the obj argument.
NewIntArrayConstruct a new primitive array object.
NewLocalRefCreates a new local reference that refers to the same object as obj.
NewLongArrayConstruct a new primitive array object.
NewObjectConstructs a new Java object. The method ID indicates which constructor method to invoke. This ID must be obtained by calling GetMethodID() with <init> as the method name and void (V) as the return type.
NewObjectArrayConstructs a new array holding objects in class clazz. All elements are initially set to obj.
NewShortArrayConstruct a new primitive array object.
NewStringUTFConstructs a new java.lang.String object from an array of characters in modified UTF-8 encoding.
PopLocalFramePops off the current local reference frame, frees all the local references, and returns a local reference in the previous local reference frame for the given result object.
PushLocalFrameCreates a new local reference frame, in which at least a given number of local references can be created.
SetBooleanArrayElementSets the value of one element in a primitive array.
SetBooleanFieldThis function sets the value of an instance (nonstatic) field of an object.
SetByteArrayElementSets the value of one element in a primitive array.
SetByteFieldThis function sets the value of an instance (nonstatic) field of an object.
SetCharArrayElementSets the value of one element in a primitive array.
SetCharFieldThis function sets the value of an instance (nonstatic) field of an object.
SetDoubleArrayElementSets the value of one element in a primitive array.
SetDoubleFieldThis function sets the value of an instance (nonstatic) field of an object.
SetFloatArrayElementSets the value of one element in a primitive array.
SetFloatFieldThis function sets the value of an instance (nonstatic) field of an object.
SetIntArrayElementSets the value of one element in a primitive array.
SetIntFieldThis function sets the value of an instance (nonstatic) field of an object.
SetLongArrayElementSets the value of one element in a primitive array.
SetLongFieldThis function sets the value of an instance (nonstatic) field of an object.
SetObjectArrayElementSets an element of an Object array.
SetObjectFieldThis function sets the value of an instance (nonstatic) field of an object.
SetShortArrayElementSets the value of one element in a primitive array.
SetShortFieldThis function sets the value of an instance (nonstatic) field of an object.
SetStaticBooleanFieldThis function ets the value of a static field of an object.
SetStaticByteFieldThis function ets the value of a static field of an object.
SetStaticCharFieldThis function ets the value of a static field of an object.
SetStaticDoubleFieldThis function ets the value of a static field of an object.
SetStaticFloatFieldThis function ets the value of a static field of an object.
SetStaticIntFieldThis function ets the value of a static field of an object.
SetStaticLongFieldThis function ets the value of a static field of an object.
SetStaticObjectFieldThis function ets the value of a static field of an object.
SetStaticShortFieldThis function ets the value of a static field of an object.
SetStaticStringFieldThis function ets the value of a static field of an object.
SetStringFieldThis function sets the value of an instance (nonstatic) field of an object.
ThrowCauses a java.lang.Throwable object to be thrown.
ThrowNewConstructs an exception object from the specified class with the message specified by message and causes that exception to be thrown.
ToBooleanArrayConvert a managed array of System.Boolean to a Java array of boolean.
ToByteArrayConvert a managed array of System.Byte to a Java array of byte.
ToCharArrayConvert a managed array of System.Char to a Java array of char.
ToDoubleArrayConvert a managed array of System.Double to a Java array of double.
ToFloatArrayConvert a managed array of System.Single to a Java array of float.
ToIntArrayConvert a managed array of System.Int32 to a Java array of int.
ToLongArrayConvert a managed array of System.Int64 to a Java array of long.
ToObjectArrayConvert a managed array of System.IntPtr, representing Java objects, to a Java array of java.lang.Object.
ToReflectedFieldConverts a field ID derived from cls to a java.lang.reflect.Field object.
ToReflectedMethodConverts a method ID derived from clazz to a java.lang.reflect.Method or java.lang.reflect.Constructor object.
ToShortArrayConvert a managed array of System.Int16 to a Java array of short.