how to call a java method with a type parameter
I've been hard at work trying to make a bluetooth plugin for android unity and I'm almost there:I have a jar file, I've imported it to Unity and I can call methods from the jar. Only problem is I have a method with a type argument and I don't know how to call a method with a type argument. Any help is appriciated.
Example java code:
package com.example;
public class ExampleClass
{
public <T> void ExampleMethod(int x)
{
//I do stuff
}
public <T> void OtherExampleMethod(String y)
{
//I do other stuff
}
}
Example C# code:
namespace ExampleClass
{
using System;
using System.Collections.Generic;
using UnityEngine;
public class ExampleClassImporter
{
AndroidJavaObject plugin = null;
public void ExampleClassInit()
{
var pluginClass = new
AndroidJavaClass("com.example.ExampleClass");
plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
}
public void <T> ExampleMethod(int x)
{
plugin.Call("ExampleMethod",x);
}
public T <T> OtherExampleMethod(string y)
{
plugin.Call<T>("OtherExampleMethod",y);
}
}
}
This is all I know, but I do not know how I can pass a type parameter. Again, any help is appriciated.
Your answer
Follow this Question
Related Questions
"Gradle Build Failed" when building for Android 0 Answers
PARSE ERROR: unsupported class file version 52.0 1 Answer
Native Plugin to get Users phone number 0 Answers
Android game export, duplicate files not found 0 Answers
PLEASE HELP! Unity interstitial ads crashing after 7 displays (in Python Kivy on my Android device) 1 Answer