Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15825] Android: Media: Camera is not accessible in Google Nexus 7 with autohide property set to false

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelsqe-3.2.0
ReporterParas Mishra
AssigneeUnknown
Created2013-11-26T09:48:09.000+0000
Updated2018-02-28T20:04:03.000+0000

Description

Android: Media: Camera is not accessible in Google Nexus 7 with autohide property false Issue is reproducible on SDK:3.1.3.GA also. Steps to reproduce: 1. Run the below app.


Ti.UI.backgroundColor = "#fff";
var win = Ti.UI.createWindow({  
        title:'Test',
        backgroundColor:'#fff',
        exitOnClose: true,
        orientationModes: [Ti.UI.PORTRAIT]
    }),
    log = function(s) {
        console.log(s);
    },
    btn = Ti.UI.createButton({
        title: "Show camera",
        top: "16dp",
        left: "16dp"
    }),
    hideSwitch = Ti.UI.createSwitch({
        titleOn: "autohide=true",
        titleOff: "autohide=false",
        value: true,
        width: Ti.UI.SIZE,
        height: Ti.UI.SIZE,
        right: "16dp",
        top: "16dp"
    }),
    overlayView = Ti.UI.createView({
        width: Ti.UI.FILL,
        height: Ti.UI.FILL
    }),
    overlayButtonClick = Ti.UI.createButton({
        width: Ti.UI.SIZE,
        height: "48dp",
        bottom: "8dp",
        left: "16dp",
        title: "Take Photo"
    }),
    overlayButtonClose = Ti.UI.createButton({
        width: Ti.UI.SIZE,
        height: "48dp",
        bottom: "8dp",
        right: "16dp",
        title: "Close"
    }),
    options = {
        cancel: function() {
            log("Cancelled");
        },
        error: function(e){
            log("Error - " + e.error);
        },
        success: function(e) {
            log("Media type: " + e.mediaType);
            log("Media size: " + e.media.length);
            makeImageView(e.media);
        },
        autohide: hideSwitch.value,
        saveToPhotoGallery: false,
        showControls: false
    },
    sv = Ti.UI.createScrollView({
        contentWidth: 'auto',
        contentHeight: 'auto',
        width: Ti.UI.FILL,
        height: Ti.UI.FILL,
        layout: 'vertical',
        top: "80dp",
        scrollType: 'vertical',
        backgroundColor: 'black'
    });

overlayView.add(overlayButtonClick);
overlayView.add(overlayButtonClose);

overlayButtonClick.addEventListener("click", function() {
	Ti.Media.takePicture();
});

overlayButtonClose.addEventListener("click", function() {
	Ti.Media.hideCamera();
});

btn.addEventListener("click", function() {
    options.autohide = hideSwitch.value;
    if (hideSwitch.value) {
        if (options.overlay) {
            delete options.overlay;
        }
    } else {
        options.overlay = overlayView;
    }
	Ti.Media.showCamera(options);
});

function makeImageView(blob) {
    sv.add(Ti.UI.createImageView({
        image: blob.imageAsThumbnail(Ti.Platform.displayCaps.platformWidth, 1, 20),
        height: (3 * 48) + "dp",
        width: (Ti.Platform.displayCaps.platformWidth - 48) + "px",
        top: "8dp"
    }));
}

win.add(btn);
win.add(hideSwitch);
win.add(sv);

win.open();
2. Set autohide=false, click on camera and take multiple pictures. Click on close. Expected: Camera should open. Actual: Error is logged as "Camera is not accessible".

Comments

No comments

JSON Source