1

I've been trying to upload images from the device gallery to an external server, but i get this error:

04-18 12:11:25.680: W/System.err(19045): java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaDocumentsProvider uri content://com.android.providers.media.documents/document/image26952 from pid=19045, uid=10243 >requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()

I added this permission in the Android Manifest, but it did not change anything. Also, I can load images and display them without any trouble, it is just the upload part that fails.

Here's the code I have:

function uploadPhoto(src) {
    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=src.substr(src.lastIndexOf('/')+1);

    var ft = new FileTransfer();
    ft.upload(src, encodeURI("http://xxxx/upload.php"), win, fail, options);
}

I have android kitkat latest version, and I'm running this on Nexus 5. Phonegap version is 3.3.

Any idea on how to deal with this error?

Thank you.

PS: here are the permissions in the android manifest xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.INTERNET" />
Onik
  • 19,396
  • 14
  • 68
  • 91
SirPsycho
  • 67
  • 1
  • 7
  • I'm having the same problem. Were you able to find the solution? – MinaHany Aug 05 '14 at 07:39
  • It turned out that the problem was not about permissions. I had an error with filenames in kitkat : http://stackoverflow.com/questions/20638932/unable-to-load-image-when-selected-from-the-gallery-on-android-4-4-kitkat-usin – SirPsycho Aug 05 '14 at 08:29
  • 1
    It also seems that the issue was fixed in phonegap 3.4.0, so upgrading to that version should resolve all problems. – MinaHany Aug 05 '14 at 09:39

1 Answers1

-1

You need to set this permission in manifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
  • Thanks for your answer, I already have it in the android manifest. I edited my first post and added the permissions in the xml file. – SirPsycho Apr 18 '14 at 10:43