title: Cordova: camera.getPicture fails with "Camera cancelled"
body: <p>I'm developing a cordova app (cli-5.2.0) in which pictures are taken using the cordova camera plugin (cordova-plugin-camera, version 1.2.0).</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var camera = navigator.camera;
  var cameraOptions = { 
    destinationType: Camera.DestinationType.DATA_URL
  };
  
  camera.getPicture(function(result) {
      alert('success');
    }, function(error) {
      alert('fail ' + error);
    }, cameraOptions);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This code works fine.. ..most of the time. <br/>
  On a particular slow android 4.4.4 device, this only works fine like 9 out of 10 times. <br/>
  In like 1 out of 10, the call fails saying 'Camera cancelled' (although it was not cancelled with the back button or something). <br/><br/></p>
  
  <p>In that case, the failure callback 'Camera cancelled' is fired, and right after that, the Camera UI is shown nevertheless. <br/>
  (if a picture is taken then, the success callback is not called). <br/><br/></p>
  
  <p>It's hard to tell when this happens, but it looks like it happens more often if the device is app is more busy. <br/>
  The log files do not show much more detail, except for things like:</p>
  
  <blockquote>
    <p>Attempted to send a second callback for ID: Camera1337050609</p>
  </blockquote>
  
  <p>However, these logs are also written if the call succeeds.</p>
  
  <p><br/>
  Any hints or help is much appreciated.<br/><br/>
  Thanks for your time,<br/>
  Koen</p>
  
  <p><strong>update 1</strong> (answer to comment)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ProjectDetailCtrl.prototype.takePhoto = function () {
      var _this = this;
      // this cameraService calls the code from above
      return this.cameraService.getPicture()
          .then(function (imageData) {
              _this.$log.debug('got camera data');
              // ..
          },</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- This is an angular application, the click handling goes like: --&gt;
  &lt;md-button ng-click="vm.takePhoto()"&gt;
      Add photo
  &lt;/md-button&gt;</code></pre>
  </div>
  </div>
  </p>