Android 4.2.2 API 17 的一些变动总结

本文深入探讨了Android开发中API更新带来的影响,特别关注API17版本下WebView与ContentProvider的变动,阐述了如何通过@JavascriptInterface注解与过滤机制增强代码安全性,以及ContentProvider默认设置由true更改为false后的应用数据保护措施。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.

http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String)

http://developer.android.com/reference/android/webkit/JavascriptInterface.html

由此可见 》=api17 的要想java 代码与网页交互,js调用的java 内部方法必须添加 该注解:@JavascriptInterface 

之前的任何的public的函数都可被js调用。这样的话可以起到过滤的作用,提高了代码的安全性。


2.

http://developer.android.com/guide/topics/manifest/provider-element.html

android:exported
Whether the content provider is available for other applications to use:
  • true: The provider is available to other applications. Any application can use the provider's content URI to access it, subject to the permissions specified for the provider.
  • false: The provider is not available to other applications. Set android:exported="false"to limit access to the provider to your applications. Only applications that have the same user ID (UID) as the provider will have access to it.

The default value is "true" for applications that set either android:minSdkVersion orandroid:targetSdkVersion to "16" or lower. For applications that set either of these attributes to "17" or higher, the default is "false".

You can set android:exported="false" and still limit access to your provider by setting permissions with the permission attribute.

由此可见 》=api17 的 ContentProvider 的上面的标签的默认值由 true 改为false. 同样提高了app内部数据的安全性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值