NativeApi.getDeviceId("123456",function (deviceid){
document.getElementById("deviceId").innerHTML = deviceid;
},
function (error){
document.getElementById("deviceId").innerHTML = error;
});
像这样js将函数作为参数来实现回调,android这边应该怎么写呢? 回调函数应该怎么办呢?
NativeApi.getDeviceId("123456",function (deviceid){
document.getElementById("deviceId").innerHTML = deviceid;
},
function (error){
document.getElementById("deviceId").innerHTML = error;
});
像这样js将函数作为参数来实现回调,android这边应该怎么写呢? 回调函数应该怎么办呢?
你这种情况应该让js调你android的代码,写个类(名字随便起) 里面加几个方法,用javascriptInterface注解一下,然后通过webview的addJavascriptInterface方法将类的对象映射到js页面,js就可以直接调
用你的方法,顺便把值传过来。