Issue
I am building an android app that have to be compatible from api 14 and newer. I have 1 method inside an javascript interface.
From api 17 you have to add an annotation to the method, the @JavascriptInterface
, but the annotation is not supported backwards api, since the app is target for api 14 I got an error. But If I dont add the annotation, the javascript is not trigged in mobile with Android 4.2.
Is it possible to make kind of ifdef if the deviceOs is newer than 4.2?
Solution
Set your build target to be API Level 17. Set your android:minSdkVersion
to be however old of Android you want to support. Then your code will compile and will have the @JavascriptInterface
annotation. Lint will point out to you places in your code where you use classes, methods, etc. that are newer than your android:minSdkVersion
, so you can make sure that you are doing so correctly.
Or, set your android:targetSdkVersion
to 16 or lower, in which case @JavascriptInterface
is not required. See http://developer.android.com/guide/webapps/webview.html#BindingJavaScript.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.