2016-02-15 31 views
0

我開發了一個基於本教程imageupload的應用程序。我能夠在我的設備上運行應用程序,但無法從圖庫中選擇圖像。當我將圖像加載到應用程序時,應用程序崩潰。我的logcat如下:Android:使用PHP MySQL上傳圖像時出現錯誤並在ListView中顯示圖像

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 

有人可以幫我解決這個問題。任何指導和幫助非常感謝。謝謝。

回答

1

它會告訴你明確:

添加到您的清單 -

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

謝謝你這麼多@Amir Horev ...我還在新this..couldnt well..Thank瞭解logcat的你再:) :) – marian

+0

很高興幫助,學會閱讀它(「引起」),它會引導你大部分時間。 –

+0

owh好吧非常感謝你的指導:) @Amir Horev – marian

相關問題