添加的接口中的所有方法都没有使用@ android.webkit.JavascriptInterface注释;它们在API 17中不可见 [英] None of the methods in the added interface have been annotated with @android.webkit.JavascriptInterface; they will not be visible in API 17
本文介绍了添加的接口中的所有方法都没有使用@ android.webkit.JavascriptInterface注释;它们在API 17中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用webview并希望加载一个JScode以在该webview中显示。但是我遇到了API16以上的问题。它从不加载JS页面。它给了我一个错误:
I am using a webview and want to load a JScode to show in that webview. However I am getting a problem above API16.It never loads the JS page. It gives me an error:
这是我的代码:
@JavascriptInterface
public void loadWebviewUrl(){
Map <String, String> extraEncryptionHeaders = new HashMap<String, String>();
extraEncryptionHeaders.put("X-APP-DEVICETYPE", "ANDROID");
appVersionname=CommonMethods.getAppVersion(WebPayUActivity.this);
extraEncryptionHeaders.put("X-APP-APPVERSIONNAME", appVersionname);
extraEncryptionHeaders.put("X-DEVICE", Constant.ANDROIDID);
extraEncryptionHeaders.put(Constant.HEADER_SECURITY_KEY, Constant.SECURITY_HASH_VALUE);
mWebView.loadUrl(mPayUrl, extraEncryptionHeaders);
**//getting error in this line that has been mentioned above**
mWebView.addJavascriptInterface(new Wscript(WebPayUActivity.this),
"Android");
screenDpi=CommonMethods.getResoltuion(this);
mWebView.setWebViewClient(new MyWebViewClient(this));
mImageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
customAlertDialog();
}
});
mWebView.setWebChromeClient(new WebChromeClient());
}
在阅读不同网站的解决方案后,我知道要添加注释。但在写完注释后,错误仍然是相同的。
After reading the solutions at different sites I got to know to add annotation. But after writing the annotation, the error is still the same.
任何人都可以检查并帮助我回来
Can anyone please check and help me back
谢谢
推荐答案
您必须添加
@SuppressLint("JavascriptInterface")
到您使用webView的公共方法对象。
to the your public methods which you used your webView object.
这篇关于添加的接口中的所有方法都没有使用@ android.webkit.JavascriptInterface注释;它们在API 17中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文