1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    7
    Vote Rating
    0
    ar6 is on a distinguished road

      0  

    Default Unanswered: PhoneGap Camera API not working with Sencha Touch 1.1.0 : Need urgent help

    Unanswered: PhoneGap Camera API not working with Sencha Touch 1.1.0 : Need urgent help


    I am writing a sencha touch(1.1.0) application using PhoneGap for iOS (XCode 4.2). I have the application structured similar to the examples having a controller, couple of views and models. I am also using PhoneGap v1.2.0 with this. However, the PhoneGap Camera API is not being called from within the controller. It works fine if written directly in index.html. Is there a special way to call PhoneGap API/ external Javascript functions from within my Ext.Controller? What else can be the reason for no call being made at all?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Answers
    3518
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Please post in the appropriate forum. I have moved this to the ST1 Q&A forum for you.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    229
    Answers
    10
    Vote Rating
    1
    umr.ashrf is on a distinguished road

      0  

    Default


    In my case I tested it on Simulator and it doesn't work there.

  4. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    7
    Vote Rating
    0
    ar6 is on a distinguished road

      0  

    Default


    Yes it wont work in the simulator as there is no camera, but it should give the "Failed" message (referring to the sample camera code given on PhoneGap Camera API webpage).
    In my case, there is no call being made at all to the navigator.camera.getPicture() method. Nothing happens on clicking the button, the app remains as is, not even the failure message.

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Answers
    3518
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by ar6 View Post
    I have posted this question in a new thread with my code snippet at this location:

    http://www.sencha.com/forum/showthre...2.0-Camera-API
    Do not double post. I have deleted that one.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    7
    Vote Rating
    0
    ar6 is on a distinguished road

      0  

    Default Code Snippet

    Code Snippet


    Here is the code snippet from my controller:
    Code:
    Ext.regController('MyController', {
               ..
               ..
        onFail:function(message) {
              alert('Failed because: ' + message);
          },
         
        onPhotoDataSuccess:function(imageData) {
              var smallImage = document.getElementById('smallImage');
              smallImage.style.display = 'block';
              smallImage.src = "data:image/jpeg;base64," + imageData;
          },
        capturePhoto:function() {
                 alert("Taking Picture");  
                navigator.camera.getPicture(onPhotoSuccess, onFail, { quality: 50 });      
        }
    The capturePhoto() is fired from the view. However, nothing happens. No error messages. The alert "Taking Picture" shows up, but thats it.
    Can anyone point out what might be the problem?

  7. #7
    Sencha User
    Join Date
    Dec 2011
    Posts
    7
    Vote Rating
    0
    ar6 is on a distinguished road

      0  

    Default Solved It

    Solved It


    Hi guys,

    I got the solution of the probelm.
    I was missing declaring the following variables:
    Code:
    var pictureSource;   // picture source
    var destinationType; // sets the format of returned value 
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.Destination;