0

I want to let the user to add a pic to the Cordova application and I would like to let the user to choose the pic from his albums or take a picture instantly. How do I provide such an option using Cordova.

Does Cordova provide such a feature out of the box or we have to write one? Please advice me how to proceed with the requirement.

Cheers!

Dipin Krishnan
  • 1,260
  • 3
  • 21
  • 41
  • [camera.getPicture()](http://cordova.apache.org/docs/en/2.5.0/cordova_camera_camera.md.html#camera.getPicture) where `Camera.sourceType` allows you to specify source as `CAMERA`, `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. – Amar Mar 17 '14 at 09:19

3 Answers3

2

Thanks a lot @GenieWanted & @Sumn2u for your responses, special thanks to @GenieWanted for your time and extended support.

From the answer for the following question I understand that there is no direct solution provided by Cordova to give the user an option to choose from multiple Camera.PictureSourceType. You have to pop a native/custom alert with option to choose from Gallery or Camera.

Cheers!

Community
  • 1
  • 1
Dipin Krishnan
  • 1,260
  • 3
  • 21
  • 41
0

Did you take a look at their Camera object? They have a clean documentation on the same. Another third party lib that you may want to look into:

https://github.com/Arcticus/Eirene/tree/master/Image%20Picker

GenieWanted
  • 4,473
  • 4
  • 24
  • 35
  • Could you please guide me what exactly in the Cordova doc I could find it? Because, I tried all the possible Camera options but non of them worked. I'm testing it on Moto G with 4.4.2 can this be an issue? Thanks for your quick response. – Dipin Krishnan Mar 17 '14 at 11:01
  • Try running the full example that is given in the link: http://docs.phonegap.com/en/3.3.0/cordova_camera_camera.md.html#Camera – GenieWanted Mar 17 '14 at 11:24
  • But before that you need to add in your config.xml – GenieWanted Mar 17 '14 at 11:26
  • In the page, they have explained each function that is related with Camera object. Andha page la full details kuduthrukaanga.. – GenieWanted Mar 17 '14 at 11:28
  • This might give you some ideas: http://www.youtube.com/watch?v=HO_59WXg33g – GenieWanted Mar 17 '14 at 11:36
  • :Thanks for your prompt reply. As you suggested executed, the full sample on Android and iOS and I couldn't get the popup where I'm able to choose Gallery or Camera. When I clicked the first 2 buttons Capture Photo & Capture Editable Photo it directly opened the camera for me to take picture. When I clicked on the other 2 buttons From Photo Library & From Photo Album both these buttons opened the library directly for me. What I'm looking forward is when I click on the button I need a popup where the user could select take picture or load from gallery. Cordova has this feature? – Dipin Krishnan Mar 17 '14 at 11:45
  • This is achievable. What you have to do is, on a button click, you can show an alert with two options (buttons). Lets say button 1 as "Load Camera" and button 2 as "pick from photos". So, if the user presses button 1, execute the function "CapturePhoto() and for button 2, execute the function getPhoto(pictureSource.PHOTOLIBRARY); – GenieWanted Mar 17 '14 at 12:09
  • Thank you so much machi! Romba nandri! – Dipin Krishnan Mar 17 '14 at 12:19
  • Github link shows 404. – Atomosk Mar 16 '17 at 03:09
0

you have to see the proper documentation of phonegap. you are using camera you can go http://docs.phonegap.com/en/3.0.0/cordova_camera_camera.md.html#Camera for camera API

and for the storage API you have to go http://docs.phonegap.com/en/3.0.0/cordova_storage_storage.md.html#Storage for storage API

By reading this two and combining these two it will work . Further you can read the whole documentation

iamsuman
  • 1,413
  • 19
  • 32