Answers for "webview communicate java android studio"

0

webview communicate java android studio

//Activity (Java)

import android.webkit.JavascriptInterface;

webView.addJavascriptInterface(new WebAppInterface(this), "Android");

public class WebAppInterface{
  Context mContext;

  /** Instantiate the interface and set the context */
  WebAppInterface(Context c) {
  mContext = c;
  }

  @JavascriptInterface   // must be added for API 17 or higher
  public void ApplicationClose() {
    //something
  }
}

//Webview (Javascript)

Android.ApplicationClose();
Posted by: Guest on March-13-2021

Code answers related to "webview communicate java android studio"

Browse Popular Code Answers by Language