首页 > 代码库 > js和android交互

js和android交互

  1. 如何提示alert
    1. webview.setWebChromeClient(new WebChromeClient() {
    2. @Override
    3. public boolean onJsAlert(WebView view, String url, String message, final JsResult resulta) {
    4. AlertDialog.Builder b2 = new AlertDialog.Builder(MainActivity.this)
    5. .setTitle("标题").setMessage(message)
    6. .setPositiveButton("ok",
    7. new AlertDialog.OnClickListener() {
    8. @Override
    9. public void onClick(DialogInterface dialog,
    10. int which) {
    11. resulta.confirm();
    12. // MyWebView.this.finish();
    13. }
    14. });
    15. b2.setCancelable(false);
    16. b2.create();
    17. b2.show();
    18. return true;
    19. }
    20. });



  2. 其他


来自为知笔记(Wiz)


js和android交互