Android targetsdkversion @JavascriptInterface

Source: Internet
Author: User

Targetsdkversion is to set the desired SDK version , if this property is set, then when the program executes, if the target device's API version is exactly equal to this value, he will tell the Android platform: This version of the program has been fully tested, no problem. It is not necessary to turn on compatibility check for this program.
That is, if the targetsdkversion is the same as the API version of the target device, it may be more efficient to run.
However, this setting is only a declaration, a notification, and will not have a substantial effect,
For example, a feature in the SDK version of Targetsdkversion is used, but this feature is not supported in the low version, so when running the program on a lower version of the API device, you may get an error: Java.lang.VerifyError. That is, this property does not help you resolve the compatibility test problem.

JS call Java, if set targetsdkversion, when targetsdkversion<17, no problem, targetsdkversion>=17 unsuccessful

If you are writing a HTML5 application and need to access the functions in Java in the JS code, you will use the WebView addjavascriptinterface () function. Because of security issues, JS can only access Java functions with @JavascriptInterface annotations in Android4.2 (if the applied android:targetsdkversion value is 17+).Before, any public function can be accessed in the JS code, while the Java object Inheritance relationship causes many public functions to be accessed in JS, one of the important functions is getclass (). Then JS can use reflection to access some other content. By introducing @JavascriptInterface annotations, you can access only the functions of @JavascriptInterface annotations in JS. This will enhance security.If your app has a android:targetsdkversion value of 17 or greater than 17, remember to add @JavascriptInterface annotations.


Android targetsdkversion @JavascriptInterface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.