# JNINativeMethod

> Defines a single method to register with a Java class using AndroidJNI.RegisterNatives.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.AndroidJNIModule

```csharp
public struct JNINativeMethod
```

## Remarks

This struct stores information about the Java method, such as its name, JNI signature, and the pointer to its corresponding native function. Registering this information using the [AndroidJNI.RegisterNatives](/engine/6000.7/script-reference/unityengine/androidjni/registernatives.md) allows you to integrate Android-specific capabilities in your Unity application.

**Note**: Use of this struct requires knowledge of Android Java Native Interface (JNI) concepts. For more information, refer to [Java Native Interface Specification (Oracle)](http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html)

## Examples

```csharp
 // Delegate definition 
delegate void JavaToCs(IntPtr jniEnv, IntPtr klass, int x);

 // Method definition
[MonoPInvokeCallback(typeof(JavaToCs))]
static void CsMethod(IntPtr jniEnv, IntPtr klass, int x)
{
    Debug.Log("From Java: " + x);
}

 // Array to be passed to AndroidJNI.RegisterNative
var methods = new JNINativeMethod[]
{
    new JNINativeMethod
    {
        name = "csMethod",
        signature = "(I)V",
        fnPtr = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(new JavaToCs(CsMethod)),
    }
};

 // Register method with the specified Java class
AndroidJNI.RegisterNatives(clazz, methods);
```

## Fields

| Value                                                                                 | Description                                                                                        |
| ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [fnPtr](/engine/6000.7/script-reference/unityengine/jninativemethod/fnptr.md)         | The pointer to the native function that is called from the Java code.                              |
| [name](/engine/6000.7/script-reference/unityengine/jninativemethod/name.md)           | The name of the Java method implemented by the corresponding native function.                      |
| [signature](/engine/6000.7/script-reference/unityengine/jninativemethod/signature.md) | The JNI method signature string that represents the parameters and return type of the Java method. |
