.getPicture Android Fail

12 posts, 0 answers
  1. KC
    KC avatar
    14 posts
    Member since:
    Feb 2013

    Posted 26 Aug 2014 Link to this post

    Greetings,

        I have an application that requires the user to either select a photo or take a picture and then upload that photo to a web service. IPhone, works fine, Android, no go. 
    The errors I get with Android are,
    Camera -> Camera Cancelled,
    Gallery -> Selection cancelled.

    This error pops up even before the Camera/Gallery opens, they open, but it has already failed so it is pointless. The simulator does not catch this. I have not been able to test it on other Android devices, but the one I know it is braking with is: Droid Maxx.

    Code Below:


    var cur = SAMPLE.models.testOneOne;
            $('#getPic').click(function () {
                navigator.camera.getPicture(
                function () {
                    alert('Success')
                },
                function (message) {
                    alert('Fail: ' + message);
                }, {
                    saveToPhotoAlbum: false,
                    quality: 10,
                    destinationType: destinationType.FILE_URI,
                    sourceType: 0,
                    encodingType: 0,
                    mediaType: 0,

                });
            })
  2. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 29 Aug 2014 Link to this post

    Hello Keith,

    Thanks for contacting us.
    I tried to reproduce your issue using our sample app on Nexus 4 Android 4.3, but of no avail. The API was working fine.

    Would you try whether you will experience the same with our sample?

    Regarding your app, I suggest debugging it on the device as described here and try it on another device if possible.
    Furthermore, you can use an emulator and debug there for example to access the gallery.

    If you need additional assistance I will be glad to help.

    Regards,
    Zdravko
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. KC
    KC avatar
    14 posts
    Member since:
    Feb 2013

    Posted 03 Sep 2014 in reply to Zdravko Link to this post

    OK,

    So, I was able to finally get the project loaded on the Droid X that we have, pain in the butt by the way, and it works just fine on it. Both the little test app and the actual application that this feature is used in.

    As far as additional information on the Droid MAXX:
    System Version: 21.11.21.obake-maxx)verizon.Verizon.en.US
    System Information: Motorola X8 Mobile Computing System
    Android Version: 4.4.4
    Baseband version: MSM8960PRO_BP_232.55.52.00R
    Kernal Version: 3.4.42-gb33f23d
    hdsplat@ca101Inxdroid70 #1

    I guess, as far as I can tell, it is just not compatible with this phone.

    I have this tracked in a support ticket, but I will keep this line open in case they find an answer/workaround on that end so I can share it here.
  4. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 08 Sep 2014 Link to this post

    Hi KC,

    I am closing this thread for now. You can reopen it at any time, by replying/posting in it. I suggest we continue the discussion in your support ticket on the same matter and update this thread after a solution is found.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  5. Jeff
    Jeff avatar
    5 posts
    Member since:
    Oct 2015

    Posted 06 Oct 2015 Link to this post

    I am having ta similar issue. The camera will take picture,but tmy app will quit w
  6. Jeff
    Jeff avatar
    5 posts
    Member since:
    Oct 2015

    Posted 06 Oct 2015 Link to this post

    sorry for the typos since  your app here doesn't let me see what I am typing
  7. Jeff
    Jeff avatar
    5 posts
    Member since:
    Oct 2015

    Posted 06 Oct 2015 Link to this post

     I am having a similar issue. The camera will take picture,but my app will quit without any error trace
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 08 Oct 2015 Link to this post

    Hello Jeff,

    I am sorry to hear you have hit a similar issue when taking picture.

    Testing the scenario on my side, I am afraid I could not observe any problem - the picture is taken and displayed on the device as expected.

    In order to be able to advice you further, may I ask you to share some additional information:
    - Do you experience the same with the Camera Sample?
    - Are there any specific errors listed if you try Debugging on Device
    - Does the issue occur on a specific mobile OS or on any?
    - Would you try running the app on a different Android device just so we can rule out the exact device module as a cause?

    Looking forward to hearing from you.

    Regards,
    Dimitrina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  9. Jeff
    Jeff avatar
    5 posts
    Member since:
    Oct 2015

    Posted 10 Oct 2015 in reply to Dimitrina Link to this post

    Hi Dimitrina,

    The phone will simple kill my application after I click the check mark after selecting the picture from the Camera or the Photo Library.


    It's probably not the problem of Cordova plugin, rather it's the problem of the phone itself.  I deployed the app from tutorial https://ccoenraets.github.io/cordova-tutorial/handlebars-templates.html and the camera worked. After a month the camera doesn't work on this project either.  


    Following are my code:
    =============Controller
      var getImage = function(){
        console.log(msg+"getImage - start");

        CameraService.getPicture(options).then(
          function(res){
            console.log(msg+"getImage success with res:");
            // $scope.member.face = "Jeff_Wang.jpg";
            if(res==="" ||res===undefined){
              showTipMsg();
              console.log(msg+"getImage, success res='"+res+"' -- image unchanged");
            }
            else{
              vm.member.face="data:image/jpeg;base64,"+res;
              picDirty=true;
              checkDirty();
              console.log(msg+"getImage, success image.length:"+res.length);
            }

          }
          ,function(err){   
            showTipMsg();   
            console.err(msg+"getImage with error: "+err+" -- use original image: "+vm.member.face);
          }


    =================Services
    .factory('CameraService', function(CameraNotAvailable,CameraAvailable) {
       var msg = "services - .factory('CameraService')::: ";
      if (navigator.camera) {
        console.log(msg+"has camera");
        return CameraAvailable;
      } else {
        console.log(msg+"has NO camera")
        return CameraNotAvailable;
      }
    })




    .service('CameraAvailable',['$q', function($q) {
       var msg = "service('CameraAvailable'::: ";
       console.log(msg+"Start");
      return {
        getPicture: function(options) {
          var q = $q.defer();


          navigator.camera.getPicture(function(result) {
            // Do any magic you need
            q.resolve(result);
            console.log(msg+"resolve");
          }, function(err) {
            console.log(msg+"err");
            q.reject(err);
          }, options);


          return q.promise;
        }
      }
    }])

    I tried to debug it and the debugger stopped at following line with null:  org.apache.cordova.CordovaInterfaceImpl

    public void setActivityResultCallback(CordovaPlugin plugin) {
    // Cancel any previously pending activity.
    if (activityResultCallback != null) {
    activityResultCallback.onActivityResult(activityResultRequestCode, Activity.RESULT_CANCELED, null);
    }
    activityResultCallback = plugin;   *********** activityResultCallback  = null here
    }

  10. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Oct 2015 Link to this post

    Hello Jeff,

    Have you eventually checked the "Don't keep activities" option in developer option menu of your phone? If so, please unselect it. Also, would you confirm you distribute and install the app on the device and not test it in the AppBuilder Companion App?

    Since the behavior replicates on your side, you can try :
    - using the adb tool that comes with the Android SDK to examine the device logs. They should have captured the exact error causing the app to crash. 
    - running the app on a different Android device just so we can rule out the exact device module as a cause. 

    In case the issue still persists, would you please send us the sample app as you are testing on, so that I can verify the exact case on my side?

    Looking forward to hearing from you.

    Regards,
    Dimitrina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  11. Jeff
    Jeff avatar
    5 posts
    Member since:
    Oct 2015

    Posted 16 Oct 2015 in reply to Dimitrina Link to this post

    Hi Dimitrina,

     The un-check on the Don't keep activities option fixed the problem.  I can take pictures using the app.

     Thanks very much!

  12. Caio
    Caio avatar
    1 posts
    Member since:
    Sep 2016

    Posted 21 Sep in reply to Jeff Link to this post

    Man, if i was a women i go to ur house now and kiss u a lot, tnks.
Back to Top