# GetMethodID

> Scans a particular Java class for a method matching a name and a signature.

## Definition

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

## GetMethodID(IntPtr, string)

Scans a particular Java class for a method matching a name and a signature.

```csharp
public static nint GetMethodID(nint javaClass, string methodName)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method as declared in Java.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first method with the correct name will be returned.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.6/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetFieldID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getfieldid.md).

## GetMethodID(IntPtr, string, string)

Scans a particular Java class for a method matching a name and a signature.

```csharp
public static nint GetMethodID(nint javaClass, string methodName, string signature)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method as declared in Java.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Method signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first method with the correct name will be returned.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.6/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetFieldID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getfieldid.md).

## GetMethodID(IntPtr, string, string, bool)

Scans a particular Java class for a method matching a name and a signature.

```csharp
public static nint GetMethodID(nint javaClass, string methodName, string signature, bool isStatic)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method as declared in Java.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Method signature (e.g. obtained by calling AndroidJNIHelper.GetSignature).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to \\\<tt\\>true\\\</tt\\> for static methods; \\\<tt\\>false\\\</tt\\> for instance (nonstatic) methods.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

The signature comparison is done to allow sub-/base-classes of a class types. If no signature is provided the first method with the correct name will be returned.

Additional Resources: [AndroidJNIHelper.GetSignature](/engine/6000.6/script-reference/unityengine/androidjnihelper/getsignature.md), [AndroidJNIHelper.GetConstructorID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getconstructorid.md), [AndroidJNIHelper.GetFieldID](/engine/6000.6/script-reference/unityengine/androidjnihelper/getfieldid.md).

## GetMethodID(IntPtr, string, Object\[], bool)

Get a JNI method ID based on calling arguments.

```csharp
public static nint GetMethodID(nint jclass, string methodName, object[] args, bool isStatic)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method as declared in Java.**** (\[Object\[]]\(https\://learn.microsoft.com/dotnet/api/system.object)): Array with parameters to be passed to the method when invoked.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to \\\<tt\\>true\\\</tt\\> for static methods; \\\<tt\\>false\\\</tt\\> for instance (nonstatic) methods.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

Generic parameter represents the method return type, and the regular method assumes 'void' return type. Scans a particular Java class for a method matching a signature based on passed arguments. The signature comparison is done to allow for sub-/base-classes of the class types.

## GetMethodID\<T>(IntPtr, string, Object\[], bool)

Get a JNI method ID based on calling arguments.

```csharp
public static nint GetMethodID<ReturnType>(nint jclass, string methodName, object[] args, bool isStatic)
```

### Parameters

**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): **** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the method as declared in Java.**** (\[Object\[]]\(https\://learn.microsoft.com/dotnet/api/system.object)): Array with parameters to be passed to the method when invoked.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to \\\<tt\\>true\\\</tt\\> for static methods; \\\<tt\\>false\\\</tt\\> for instance (nonstatic) methods.

### Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### Remarks

Generic parameter represents the method return type, and the regular method assumes 'void' return type. Scans a particular Java class for a method matching a signature based on passed arguments. The signature comparison is done to allow for sub-/base-classes of the class types.
