简体   繁体   中英

Permission Denial: opening provider MediaDocumentsProvider in API 21

I'm working on APP where I give option to record or select already stored videos. I'm able to perform these operations without any issue. But when I close the activity and open it again, my activity isn't able to access the URIs again.

I get the exception: D/MediaPlayer: setDataSource SecurityException happend :

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{2e396c8 6917:com.rahul.android.casteeng/u0a145} (pid=6917, uid=10145) requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3654)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5299)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2966)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1495)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1115)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:970)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:897)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1108)
at android.widget.VideoView.openVideo(VideoView.java:376)
at android.widget.VideoView.access$2100(VideoView.java:73)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:657)
at android.view.SurfaceView.updateWindow(SurfaceView.java:682)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:200)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:921)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2214)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1230)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6748)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

I have already configured permission in AndroidMenifest.xml as

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

Any suggestion will be helpful. Thanks in advance!

I had tried adding run time permissions also but nothing worked for me. I updated my Samsung tab and seems like new updates solved this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM