0

I have developed an app based on this tutorial imageupload. I am able to run the app in my device but could not select images from gallery.The app crashes when i load image into the app. My logcat is as follows:

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

Can someone help me to solve this issue. Any guidance and help is much appreciated. Thank you.

1 Answer 1

1

It tells you clearly:

add to your manifest -

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
3
  • Thank you so much @Amir Horev...im still new to this..couldnt understand the logcat well..Thank you again :)
    – marian
    Commented Feb 15, 2016 at 2:10
  • Glad to help, learn to read it ("Caused by" line) and it will guide you most of the times.
    – Amir Horev
    Commented Feb 15, 2016 at 2:11
  • owh okay thank u so much for the guidance :) @Amir Horev
    – marian
    Commented Feb 15, 2016 at 2:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.