JavaScript web interface

I am creating a mobile application that should interact with java in javascript.

I found a solution in this link Passing an array of values โ€‹โ€‹from Android Activity to JavaScript in a WebView . But my problem is that I declare that the webview is showing my error, for example

None of the methods of the added interface were annotated @ Android.webkit.JavascriptInterface; they will not be visible in API 17

What to do to remove this error? I am very new to this Java kernel. Please suggest me and help me solve this problem.

+7
java javascript android webview
source share
2 answers

From the docs:

Caution If you set targetSdkVersion in 17 or later, you must add the @JavascriptInterface annotation to any method by which you want to get the code for your web page (this method must also be public), if you do not provide the annotation, the method will not be available your web page when running on Android 4.2 or higher.

Please see here http://developer.android.com/guide/webapps/webview.html

+6
source share

You must add

@SuppressLint("JavascriptInterface") 

to your public methods that you used for your web object.

+2
source share

All Articles