Android targetSdkVersion 17 @JavascriptInterface

Go to: http://blog.csdn.net/zzf112/article/details/19546859

 

--------------------------------------------------------------------------------------------

 

targetSdkVersion is to set the desired SDK version . If this property is set, when the program is executed, if the API version of the target device is exactly equal to this value, it will tell the Android platform that the program has been fully tested in this version and there is no problem. There is no need to turn on the work of compatibility check judgment for this program.
That is to say, if the targetSdkVersion is the same as the API version of the target device, the operation efficiency may be higher. 
However, this setting is only a statement, a notification, and will not have a very substantial effect.
For example, if a feature in the SDK version of targetSdkVersion is used, but this feature is not supported in the lower version, then in the lower version When running the program on the API device of , an error may be reported: java.lang.VerifyError. That said, this property won't help you with compatibility testing issues.

 

When js calls java, if targetSdkVersion is set, there is no problem when targetSdkVersion<17, and it is unsuccessful when targetSdkVersion>=17

 

If you are writing an HTML5 application and need to access functions in Java in JS code, you will use the addJavascriptInterface() function of WebView. Due to security issues, in Android 4.2 (if the application's android:targetSdkVersion value is 17+), JS can only access Java functions annotated with @JavascriptInterface.

Before, any Public function could be accessed in JS code, and the Java object inheritance relationship will lead to many Public functions can be accessed in JS, one of the important functions is getClass(). Then JS can access some other content through reflection. By introducing the @JavascriptInterface annotation, only functions annotated with @JavascriptInterface can be accessed in JS. This enhances security.

If your application's android:targetSdkVersion value is 17 or greater, remember to add the @JavascriptInterface annotation.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327106831&siteId=291194637