展开全部
Android平台上使用js调用java方法,主要是通过webview控件提供的 webview.addJavascriptInterface(new Person(this), "per"); 这个方法将java对象注入到js中,然后可以在js中通e68a84e8a2ad3231313335323631343130323136353331333339666663过调用该java对象的方法来实现回调,如下代码:
1.html文件,demo.html
function updateHtml(type,type2){
document.getElementById("content").innerHTML =
"弹出对话框,测试"+type+type2;
alert("dialog");
}
这是一个js与android的例子 弹出对话框
调用对象方法 调用对象方法
2.android端控制代码:package com.ccb.javascript;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
impor