Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-16199

Android: camera with overlay takePicture() firing success function multiple times

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 3.4.0
    • Component/s: None
    • Environment:

      Samsung Galaxy Note 2
      Android, version: 4.1.1
      Titanium Studio 3.2.0.201312191547
      Titanium Mobile SDK 3.2.0GA

    • Sprint:
      2014 Sprint 11 SDK, 2014 Sprint 14 SDK

      Description

      The takePicture() function on Android is firing the success function multiple (3) times when using a custom camera overlay. Example:

      app.js

      // Containing window
      var win = Ti.UI.createWindow({
          navBarHidden: true,
          backgroundColor: "#ffffff",
          height: Ti.UI.FILL,
          width: Ti.UI.FILL
      });
       
      // Blue button that opens the camera
      var open_camera = Ti.UI.createButton({
          height: Ti.UI.SIZE,
          width: Ti.UI.SIZE,
          bottom: 50,
          title: 'Camera'
      });
      // Adding the "open camera" button
      win.add(open_camera);
       
      // Function to show the camera
      function openCamera(){
          alert('opening');
          open_camera.backgroundColor = "#00ff00"; // Just checking if we got here
       
          // The camera overlay I want displayed over the camera
          var camera_overlay = Ti.UI.createView({
              top: 0,
              left: 0,
              height: Ti.UI.FILL,
              width: Ti.UI.FILL
          });
       
          var take_picture = Ti.UI.createButton({
              height: Ti.UI.SIZE,
              width: Ti.UI.SIZE,
              bottom: 50,
              title: 'Take Picture'
          });
          take_picture.addEventListener('click', function () {
              Ti.Media.takePicture();
          });
          camera_overlay.add(take_picture);
       
          // The actual show camera part
          Ti.Media.showCamera({
              success:function(e)
              {
                  alert('success'); // I want this!
              },
              cancel:function(e)
              {
              },
              error:function(error)
              {
              },
              autohide: false,
              showControls: false,
              mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
              overlay: camera_overlay // The camera overlay being added to camera view
          });
      };
       
      // Click event to show the camera
      open_camera.addEventListener("click", function(e){
          openCamera();
      });
       
      // Open the window
      win.open();
      

      log:

      [INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 17.483MB for 1811991-byte allocation
      [INFO] :   ALERT: (KrollRuntimeThread) [6602,83973] success
      [INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 19.187MB for 1363520-byte allocation
      [INFO] :   ALERT: (KrollRuntimeThread) [248,84221] success
      [INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 20.975MB for 1830730-byte allocation
      [INFO] :   ALERT: (KrollRuntimeThread) [281,84502] success
      

      Reference: http://developer.appcelerator.com/question/161324/android-camera-taking-3-pictures-at-a-time

        Attachments

          Activity

            People

            • Assignee:
              pwang Ping Wang
              Reporter:
              mfogg Mike Fogg
              Reviewer:
              Hieu Pham
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-18199
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code