Data passed directly in Activity must be serialized. How to serialize JSCallback?
迷茫2017-05-16 13:34:53
JSCallback throws the result into the callback function, and this result can be inserted through JSCallback's invoke. For example:
@JSMethod(uiThread = false)
public void getLoginInfo(String name,JSCallback success,@Nullable JSCallback error) {
Map<String, Object> options = new HashMap<>();
options.put("name",name);
success.invoke(options); //丢到js的成功回调里面
if(error!=null){
error.invoke(null); //丢到js的失败回调里面
}
}
Invoke passes in object, and the front end will automatically parse it. If it is a map, the front end js will get the json object;
Your question is rather vague, you can describe the usage scenario in detail. JSCallback itself is a callback tool, why serialize it?