gpt4 book ai didi

php - Android:使用PHP MySQL上传图片并在ListView中显示图片时出错

转载 作者:行者123 更新时间:2023-11-29 11:43:16 25 4
gpt4 key购买 nike

我根据本教程开发了一个应用程序imageupload 。我可以在我的设备中运行该应用程序,但无法从图库中选择图像。当我将图像加载到应用程序中时,该应用程序崩溃了。我的logcat如下:

02-15 09:45:24.263    9846-9846/com.example.dothis.imagefeed E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.dothis.imagefeed, PID: 9846
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/2501 (has extras) }} to activity {com.example.dothis.imagefeed/com.example.dothis.imagefeed.MainActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/2501 from pid=9846, uid=10222 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.app.ActivityThread.deliverResults(ActivityThread.java:3681)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3724)
at android.app.ActivityThread.access$1400(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/2501 from pid=9846, uid=10222 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1465)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:148)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:682)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1067)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
at android.content.ContentResolver.openInputStream(ContentResolver.java:632)
at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:838)
at com.example.dothis.imagefeed.MainActivity.onActivityResult(MainActivity.java:71)
at android.app.Activity.dispatchActivityResult(Activity.java:5650)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3677) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3724)at android.app.ActivityThread.access$1400(ActivityThread.java:175)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5603)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:515)at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)at dalvik.system.NativeStart.main(Native Method)
02-15 09:45:26.718 9846-9846/com.example.dothis.imagefeed I/Process﹕ Sending signal. PID: 9846 SIG: 9

有人可以帮我解决这个问题吗?非常感谢任何指导和帮助。谢谢。

最佳答案

它清楚地告诉你:

添加到您的 list -

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

关于php - Android:使用PHP MySQL上传图片并在ListView中显示图片时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35400389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com