android - How to serialize JSCallback callback function (Android)
淡淡烟草味
淡淡烟草味 2017-05-16 13:32:53
0
1
1109

Data passed directly in Activity must be serialized. How to serialize JSCallback?

淡淡烟草味
淡淡烟草味

reply all(1)
迷茫

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?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template