9 Replies Latest reply on Sep 14, 2017 5:39 AM by piero.alberto

    navigator.camera.getPicture doens't work

    piero.alberto Level 1

      I'm using phonegap with DevExtreme and I'd like to use the phone camera.

       

      I searched for the code I need and I'm trying this:

       

       

          function capturePhoto() {
              alert("1");
              navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
                  quality: 50,
                  destinationType: navigator.camera.DestinationType.FILE_URI,
              });
          }
      

       

          function onPhotoDataSuccess(imageData) {
              alert("S");
              var smallImage = document.getElementById('smallImage');
              smallImage.style.display = 'block';
              smallImage.src = "data:image/jpeg;base64," + imageData;
              image = "data:image/jpeg;base64," + imageData;
              alert("Image = " + image);
          }
      
      
          function onFail(message) {
              alert('Failed because: ' + message);
          }
      

       

      The alert("1") in the capturePhoto function is showed, but after this nothing happens.

       

      I don't know if I'm missing something, but the code seems correct. I'm trying it on a real Android device. Further, I don't know if onSuccess is correct. For example, I can't understand why there is document.getElementById('smallImage'). What's wrong with my code? DevExtreme support tells on their side is all correct.

       

      This is my config.xml:

       

      <widget id="com.devexpress.apptemplate" version="1.0" versionCode="1">
        <name>ApplicationTemplate</name>
        <description>Template</description>
        <author email="info@info.com" href="http://www.info.com/">Info</author>
        <preference name="permissions" value="none" />
        <preference name="prerendered-icon" value="true" />
        <preference name="android-windowSoftInputMode" value="adjustPan" />
        <preference name="SplashScreen" value="splash" />
        <preference name="SplashScreenDelay" value="60000" />
        <preference name="AutoHideSplashScreen" value="false" />
        <preference name="SplashShowOnlyFirstTime" value="false" />
        <preference name="FadeSplashScreen" value="false" />
        <preference name="ShowSplashScreenSpinner" value="false" />
        <preference name="DisallowOverscroll" value="true" />
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="StatusBarBackgroundColor" value="#000000" />
        <preference name="android-minSdkVersion" value="14" />
        <preference name="android-targetSdkVersion" value="22" />
        <!--<plugin name="cordova-plugin-file" />-->
        <plugin name="cordova-plugin-camera" />
        <plugin name="cordova-plugin-splashscreen" onload="true" />
        <plugin name="cordova-plugin-whitelist" />
        <plugin name="cordova-plugin-ios-longpress-fix" />
        <plugin name="cordova-plugin-statusbar" onload="true" />
        <access origin="*" />
      </widget>