0

I am trying to develop a PhoneGap app with the latest version of phonegap. Inside my app contain a page where it allows user to change their profile image. I am trying to do it with html standard fileupload element. But the problem is, it does work on certain android phone, but some others not working at all. At first I am thinking because of Android version, but there is case where it works on Samsung Galaxy tab 10.1 with Android 4.1.2, but not working with another same version of Android phone.

So, what is the proper / solid way to have select image from gallery function to work properly across all supported android devices?

Thank you.

user1995781
  • 19,085
  • 45
  • 135
  • 236

1 Answers1

1

You can use the Cordova's camera plugin to select image from the gallery. Here is the cordova's documentation link http://cordova.apache.org/docs/en/3.5.0/cordova_plugins_pluginapis.md.html#Plugin%20APIs

Here is the github link to the plugin https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md

You can just change the source type as Photolibrary,to access image from gallery

sourceType: Camera.PictureSourceType.PHOTOLIBRARY,

Incase you are using a phonegap project instead of cordova,the same is applicable as phonegap also uses cordova's plugin

You might encounter an error while uploading the pic in the latest version of Android.The workaround for this is in the link Unable to set image source when accessing image from gallery-Android

All the best

Community
  • 1
  • 1
ShinyJos
  • 1,487
  • 11
  • 17
  • Thanks for your answer. I tried, but when I click on the button, nothing happen. No dialog box or anything at all appear. Do I need to download the plugin in order to use it? What if I compile my app at PhoneGap build? – user1995781 Jul 14 '14 at 09:11
  • Yes you have to download and install the plugin.I never used phonegap build...sorry – ShinyJos Jul 17 '14 at 07:00