我有一個活動,意圖過濾器android.intent.action.SEND
與圖片MIME類型。訪問DownloadProvider時避免SecurityException
一旦用戶共享照片(專門從下載管理器)與我的活動(UploadActivity),活動將檢查用戶是否登錄。如果不是,它將存儲原意(與EXTRA_STREAM
)並將用戶發送到LoginActivity。一旦該用戶登錄,他將以原始保存的意圖被帶回到UploadActivity。
現在,即使恢復原來的意圖後,我得到一個java.lang.SecurityException: Permission Denial: reading com.android.providers.downloads.DownloadProvider uri...
。
我明白爲什麼我會得到這個。這是因爲我沒有原始意圖的臨時許可。
編輯:logcat的
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.UploadActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.downloads.DownloadProvider uri content://downloads/all_downloads/1145 from pid=16585, uid=10086 requires android.permission.ACCESS_ALL_DOWNLOADS, or grantUriPermission()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.downloads.DownloadProvider uri content://downloads/all_downloads/1145 from pid=16585, uid=10086 requires android.permission.ACCESS_ALL_DOWNLOADS, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1425)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:372)
at android.content.ContentResolver.query(ContentResolver.java:315)
at com.example.UploadActivity.getFileFromContentUri(UploadActivity.java:304)
at com.example.UploadActivity.onCreate(UploadActivity.java:195)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
... 11 more
請發佈所有的LogCat錯誤。可以肯定的是,你有'INTERNET'權限嗎? – Sam 2013-03-05 17:40:41
原始帖子已更新。是的,我擁有「INTERNET」權限。這是我擁有的唯一權限。 – ademers 2013-03-05 17:51:00
@AWebDevDuh:你還添加了'android.permission.ACCESS_ALL_DOWNLOADS'權限? – 2013-03-05 17:52:22