Advertisement

Android Studio开发安卓应用与WebView中的JavaScript交互

阅读量:

基于Android Studio进行安卓应用程序的开发过程中,涉及安卓系统与WebView组件中JavaScript代码的交互机制

1.webview中的页面调用android中的方法

Android Studio开发安卓app 封装WEB(H5,URL)的基础上新增此功能

1. APP新增 JsInteration.java

复制代码
    package com.bsoft.myapplication;
    
    import android.speech.tts.TextToSpeech;
    import android.util.Log;
    import android.webkit.JavascriptInterface;
    
    /** *
     * author:gaom
     * @since: 2022/6/14 9:11
     * desc: 安卓与webview html 中的 js交互
     */
    public class JsInteration {
    TextToSpeech textToSpeech;
    public JsInteration(TextToSpeech textToSpeech){
        this.textToSpeech=tex

全部评论 (0)

还没有任何评论哟~