user1995781
user1995781

Reputation: 19453

Phonegap solid way of select image from gallery

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.

Upvotes: 0

Views: 719

Answers (1)

ShinyJos
ShinyJos

Reputation: 1487

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

Upvotes: 1

Related Questions