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

Android: Error in Upload Image Using PHP MySQL and Display Images in ListView

我根据本教程开发了一个应用程序imageupload。我可以 运行 我设备中的应用程序,但无法 select 来自 gallery.The 的图像 当我将图像加载到应用程序时崩溃。我的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.access00(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.access00(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

谁能帮我解决这个问题。非常感谢任何指导和帮助。谢谢。

明明白白的告诉你:

添加到您的清单 -

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