I am getting None of the methods in the added interface @android.webkit.JavascriptInterface.They will not be visible in Api level 17.
compile error at addJavascriptInterface method.
I have pointed out the error line in below code:
WebView code:
import android.webkit.JavascriptInterface;
webView = (WebView) findViewById(R.id.load_url);
webView.getSettings().setJavaScriptEnabled(true);
if (new File(url).exists()) {
webView.loadUrl(FILENAME_PREFIX + url);
Log.d("fileurl", "" + FILENAME_PREFIX + url);
}
webView.addJavascriptInterface(new Object() { --->None of the methods in the added interface @android.webkit.JavascriptInterface.They will not be visible in Api level 17.
@JavascriptInterface
public void performClick() {
Intent intRef=new Intent(FirstActivity.this,SecondActivity.class);
startActivity(intRef);
}
}, "ok");
Html Code:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div>
<button type="button" onclick="ok.performClick();">OK</button>
</div>
</body>
</html>
I am using minSdkVersion 11 and targetSdkVersion 22.I had called @JavascriptInterface in before method.You could see that in above code.
Anyone can help me with this.Thank you.