Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android java.lang.SecurityException:权限拒绝:读取(…)提供程序uri_Android_Android Service_Android Contentprovider - Fatal编程技术网

Android java.lang.SecurityException:权限拒绝:读取(…)提供程序uri

Android java.lang.SecurityException:权限拒绝:读取(…)提供程序uri,android,android-service,android-contentprovider,Android,Android Service,Android Contentprovider,我得到了一些关于在内容提供者中执行查询时抛出的异常的报告。这些报告大多来自使用安卓2.3的用户,目前我在安卓4.x中没有关于这个问题的报告 内容提供者是完全私有的,不导出,只在声明它的应用程序中使用,所以我真的不明白为什么会发生这种SecurityException 我的提供者声明如下,在标记中: <provider android:authorities="com.some.authority" android:exported="false"

我得到了一些关于在内容提供者中执行查询时抛出的异常的报告。这些报告大多来自使用安卓2.3的用户,目前我在安卓4.x中没有关于这个问题的报告

内容提供者是完全私有的,不导出,只在声明它的应用程序中使用,所以我真的不明白为什么会发生这种SecurityException

我的提供者声明如下,在标记中:

    <provider
        android:authorities="com.some.authority"
        android:exported="false"
        android:name="com.myapp.provider" />
我试图寻找这个问题,但我找不到另一个像我这样的案例。我还检查了与内容提供商相关的文档,但我仍然不知道为什么会发生这种异常

我希望有人能解释一下这个问题

提前非常感谢

PS.忘了说查询是在与内容提供商属于同一应用程序的服务中执行的,但该服务在单独的进程中运行。无论如何,我在另一个应用程序中也收到了关于同一问题的报告,在这种情况下,查询是在主进程中执行的,因此我认为执行查询的进程根本不重要

编辑:

这是完整的堆栈跟踪:

java.lang.SecurityException: Permission Denial: reading com.myapp.provider uri content://com.some.authority/something from pid=16201, uid=10139 requires null
   at android.os.Parcel.readException(Parcel.java:1322)
   at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
   at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
   at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
   at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
   at android.content.ContentResolver.query(ContentResolver.java:262)
   at com.myapp.services.CustomService.onHandleIntent //-> THIS IS WHERE THE QUERY IS EXECUTED
   at com.myapp.services.BackgroundService$ServiceHandler.handleMessage
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:130)
   at android.os.HandlerThread.run(HandlerThread.java:60)

请发布堆栈跟踪。您确定SecurityException来自您的代码吗?我刚刚编辑了消息以包含堆栈跟踪。requires null位通常与试图访问非导出组件的人关联。你试过在2.3模拟器上重现这个问题吗?是的,我试过在2.3模拟器上重现这个错误,但没有成功。一切都很完美。我也收到了关于Android 3.1和3.2中发生的这个问题的报告
java.lang.SecurityException: Permission Denial: reading com.myapp.provider uri content://com.some.authority/something from pid=16201, uid=10139 requires null
   at android.os.Parcel.readException(Parcel.java:1322)
   at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
   at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
   at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)
   at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
   at android.content.ContentResolver.query(ContentResolver.java:262)
   at com.myapp.services.CustomService.onHandleIntent //-> THIS IS WHERE THE QUERY IS EXECUTED
   at com.myapp.services.BackgroundService$ServiceHandler.handleMessage
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:130)
   at android.os.HandlerThread.run(HandlerThread.java:60)