Last active
April 26, 2017 17:10
-
-
Save Ansh1234/13a514c9c24efd1365001667c689f2f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebViewJsInterface { | |
private WebView webView; | |
private Context context; | |
public WebViewJsInterface(Context context, WebView webView) { | |
this.webView = webView; | |
this.context=context; | |
} | |
@JavascriptInterface | |
public void handleMessage(String message) { | |
Toast.makeText(context, message, Toast.LENGTH_LONG).show(); | |
} | |
@JavascriptInterface | |
public void setWebViewTextCallback(){ | |
String script = WebViewUtils.formatScript("setText","This is a text from Android which is set " + | |
"in the html page."); | |
WebViewUtils.callJavaScriptFunction(webView,script); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment