android:exported对ContentProvider的影响
16lz
2021-12-04
前两天按教学视频在MainActivity中写完ContentProvider后在Manifest中配置了如下代码
<provider android:name="test.provider.SQLiteProvider" android:authorities="test.provider" />
然而并不能传递内容,当时在网上找并没有找到明确答案,有的在provider配置了许多内容,偶然加上了一句android:exported="true" ,碰巧成功了,但是并不知道缘由。
今日细看SDK文档,发现端倪。
android:exportedWhether 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 or android: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.
据鄙人E渣的翻译,大意是最小SDK版本或者目标SDK版本小于等于16的,则默认值为“true”,else ,默认值为"false"。
由于教学视频为12年的,所以版本较老,而我用了最新的,不可避免产生差别。因此对于现在大部分人来说,是需要配置一下export较为妥当。
<provider android:name="test.provider.SQLiteProvider" android:authorities="test.provider" android:exported="true" />
更多相关文章
- java/jdk版本不对导致android编译错误
- No cached version of com.android.tools.build:gradle:3.6.3 av
- Android各版本对应的SDK和JDK版本
- android studio3.6.3编译Telegram android 1482 问题小记(nebula
- android 修改电脑盘符名称 USB连接电脑默认连接方式
- Android(安卓)7.1 源码编译
- 编译 Android版本的Openal方式
- 关于android studio出现Gradle sync failed: Plugin is too old,
- [android] No resource found that matches the given name 'The