To expose java methods to javascript, I used
mWebview.addJavascriptInterface(new JSInterface(this),"Android");
When I am actually in the JSInterface, how would I get the webview the JavascriptInterface was added to?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume you are still dealing with the 2 webviews described here:
How to handle callbacks in webview
You cannot determine what webview the JavaScript interface is attached to. Not without doing some preparation upfront. Some options are:
Use a different interface name for each webview and then test which one is present to determine which webview you are in.
Use the same interface, but have each function in the interface include a parameter called caller which has the number of the calling webview.