Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android camera taking 3 pictures at a time

$
0
0

I've been trying to get a simple camera app working on android and running into problem after problem... so any help would be much appreciated!

I've managed to get the camera view to take a picture after debugging on this Q&A.

Now that the image is being taken (woo!) it's actually doing even better, it's taking 3 pictures! That would be nice if I wanted three pictures to be taken.

Using this simple code:

// 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();
I'm seeing it fire that success call 3 times when I click "Take Picture":
[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
My Device Info:

Samsung Galaxy Note 2 Titanium 3.2.0

{ osname: android, version: 4.1.1, height: 1280, width: 720, dpi: 320 };


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>