Java 在Android WebAppInterface中传递对象
我想在WebAppInterface上提供一个Card对象列表,但在WebView端只能得到一个空的Json对象。我肮脏的解决方法是在webview中将其作为JSON end解码传递。正确的方法是什么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() {
// 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);}
看:好的,谢谢;)我试图以重复的方式结束这个问题