欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord

程序员文章站 2022-06-05 14:22:38
...
11-18 11:26:11.018  1110  1141 W ActivityManager: Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord{cbef6f 17448:com.android.gallery3d/u0a126} (pid=17448, uid=10126) that is not exported from UID 10185
11-18 11:26:11.020 17448 17488 W AsyncQuery: Exception thrown during handling EVENT_ARG_QUERY
11-18 11:26:11.020 17448 17488 W AsyncQuery: java.lang.SecurityException: Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord{cbef6f 17448:com.android.gallery3d/u0a126} (pid=17448, uid=10126) that is not exported from UID 10185
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Parcel.createException(Parcel.java:2357)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Parcel.readException(Parcel.java:2340)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Parcel.readException(Parcel.java:2282)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5728)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.app.ActivityThread.acquireProvider(ActivityThread.java:6861)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2935)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2484)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.content.ContentResolver.query(ContentResolver.java:1169)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.content.ContentResolver.query(ContentResolver.java:1116)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.content.ContentResolver.query(ContentResolver.java:1072)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.content.AsyncQueryHandler$WorkerHandler.handleMessage(AsyncQueryHandler.java:79)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Handler.dispatchMessage(Handler.java:106)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Looper.loop(Looper.java:223)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.HandlerThread.run(HandlerThread.java:67)
11-18 11:26:11.020 17448 17488 W AsyncQuery: Caused by: android.os.RemoteException: Remote stack trace:
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:7230)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7670)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2397)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2898)
11-18 11:26:11.020 17448 17488 W AsyncQuery:  at android.os.Binder.execTransactInternal(Binder.java:1159)

修改方案:

Intent intent = new Intent(Intent.ACTION_VIEW);
//添加下面一行
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);