Java Unity JNI,获取ArrayList<;哈希表<;字符串,字符串>&燃气轮机;来自C语言中的Android本机#
有谁能帮我在Unity C中使用Java Unity JNI,获取ArrayList<;哈希表<;字符串,字符串>&燃气轮机;来自C语言中的Android本机#,java,c#,unity3d,java-native-interface,hashtable,Java,C#,Unity3d,Java Native Interface,Hashtable,有谁能帮我在Unity C中使用ArrayList 我可以从android原生库中获取布尔值和字符串,没有问题,但这一个让我 public ArrayList<Hashtable<String, String>> getProducts() { return pluginClass.CallStatic<ArrayList<Hashtable<String, String>>>("getProductList"); } publi
ArrayList
我可以从android原生库中获取布尔值和字符串,没有问题,但这一个让我
public ArrayList<Hashtable<String, String>> getProducts()
{
return pluginClass.CallStatic<ArrayList<Hashtable<String, String>>>("getProductList");
}
public ArrayList getProducts()
{
返回pluginClass.CallStatic(“getProductList”);
}
非常感谢
using System.Collections.Generic;
public AndroidJavaOject getProducts()
{
return pluginClass.CallStatic<AndroidJavaOject>("getProductList");
}
在C侧
public-void-getProducts()
{
string json=(string)pluginClass.CallStatic(“getProductList”);//或
//字符串json=pluginClass.CallStatic(“getProductList”).ToString();
//您可以使用任何json库来反序列化json
Debug.Log(json);//确保这是您希望获得的正确字符串
}
给定json字符串,从中删除产品列表更方便。Hi mate,感谢您的帮助,这会引发以下错误,无法将类型
UnityEngine.AndroidJavaObject'隐式转换为System.Collections.Generic.list'
public String getProducts(){
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(productListObject);
return json;
}
public void getProducts()
{
string json = (string) pluginClass.CallStatic<AndroidJavaOject>("getProductList"); //or
//string json = pluginClass.CallStatic<AndroidJavaOject>("getProductList").ToString();
//You can use any json library to deserialize the json then
Debug.Log(json); // Make sure this is correct string you wish to get
}