Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Android WebAppInterface中传递对象_Java_Android_Json_Android Webview_Gson - Fatal编程技术网

Java 在Android WebAppInterface中传递对象

Java 在Android WebAppInterface中传递对象,java,android,json,android-webview,gson,Java,Android,Json,Android Webview,Gson,我想在WebAppInterface上提供一个Card对象列表,但在WebView端只能得到一个空的Json对象。我肮脏的解决方法是在webview中将其作为JSON end解码传递。正确的方法是什么 // not working: @JavascriptInterface public List<Card> getCards() { return cards; } // dirty: @JavascriptInterface public String getCards() {

我想在WebAppInterface上提供一个Card对象列表,但在WebView端只能得到一个空的Json对象。我肮脏的解决方法是在webview中将其作为JSON end解码传递。正确的方法是什么

// not working:
@JavascriptInterface
public List<Card> getCards() { return cards; }

// dirty:
@JavascriptInterface
public String getCards() { return gson.toJson(cards); }
//不工作:
@JavascriptInterface
public List getCards(){return cards;}
//肮脏的:
@JavascriptInterface
公共字符串getCards(){return gson.toJson(cards);}
看:好的,谢谢;)我试图以重复的方式结束这个问题