概述
我的代码行有问题:
String path = MediaStore.Images.Media.insertImage(activity.getContentResolver(), bitmap, "feedback", null);
Activity不为null,位图不为null.
我收到错误:
0-22 11:23:59.644 29514-29527/? E/DatabaseUtils: Writing exception to parcel
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=1380, uid=10136 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: at android.content.ContentProvider.enforceWritePermissionInner(ContentProvider.java:679)
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: at android.content.ContentProvider$Transport.enforceWritePermission(ContentProvider.java:494)
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: at android.content.ContentProvider$Transport.insert(ContentProvider.java:258)
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:163)
10-22 11:23:59.644 29514-29527/? E/DatabaseUtils: at android.os.Binder.execTransact(Binder.java:453)
10-22 11:23:59.645 1380-1467/? E/MediaStore: Failed to insert image
10-22 11:23:59.645 1380-1467/? E/MediaStore: java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=1380, uid=10136 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.os.Parcel.readException(Parcel.java:1599)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.content.ContentResolver.insert(ContentResolver.java:1231)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:962)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at com.azimo.sendmoney.a.utils.Screenshot$1.call(Screenshot.java:58)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at com.azimo.sendmoney.a.utils.Screenshot$1.call(Screenshot.java:51)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at rx.Observable.unsafeSubscribe(Observable.java:7531)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at rx.internal.operators.OperatorSubscribeOn$1$1.call(OperatorSubscribeOn.java:62)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
10-22 11:23:59.645 1380-1467/? E/MediaStore: at java.lang.Thread.run(Thread.java:818)
我的清单中有权限:
适用于5.1.1 Nexus 4.不适用于6.0 Nexus 6.
你知道我怎么能解决它?也许以编程方式添加一些权限?
最后
以上就是跳跃导师为你收集整理的android mediastore.images.media.insertimage,android – MediaStore.Images.Media.insertImage在某些设备上抛出权限拒...的全部内容,希望文章能够帮你解决android mediastore.images.media.insertimage,android – MediaStore.Images.Media.insertImage在某些设备上抛出权限拒...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复