情景:1、A,B两个程序,A程序提供ContentProvider;B程序访问A程序的ContendProvider
2、在A程序中已经添加权限:
<provider android:name=".provider.UserProvider" android:authorities="com.example.listview.userprovider"></provider>
问题:A程序部署后,再运行B程序,报错:
03-11 21:48:38.336: E/AndroidRuntime(2035): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.example.listview.provider.UserProvider from ProcessRecord{4190d088 2035:com.example.callcontentprovider/u0a10053} (pid=2035, uid=10053) that is not exported from uid 10052
解决:
在A程序的清单文件中provider组件注册没有添加被外部调用的属性,完整provider在清单文件中注册如下:
<provider android:exported="true" android:name=".provider.UserProvider" android:authorities="com.example.listview.userprovider"></provider>