Skip to content

Instantly share code, notes, and snippets.

@jgyurkovitz
Created December 7, 2010 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgyurkovitz/731401 to your computer and use it in GitHub Desktop.
Save jgyurkovitz/731401 to your computer and use it in GitHub Desktop.
My trials with trying to get my camera app to work on android.
/***********************************************
** Version that should work but doesn't **
***********************************************/
Titanium.UI.setBackgroundColor('#000');
var cameraWindow = Titanium.UI.createWindow({
backgroundColor:'#FFF'
});
var startVideoButton = Titanium.UI.createButton({
bottom:10, width:120, height:40,
title:'Start Video'
});
var overlay = Titanium.UI.createView();
overlay.add(startVideoButton);
Titanium.Media.showCamera({
overlay:overlay,
showControls:false,
success:function(event)
{
Ti.API.debug("video was taken");
},
cancel:function(){},
error:function(error)
{
var a = Titanium.UI.createAlertDialog({title:'Camera'});
if (error.code == Titanium.Media.NO_CAMERA)
{
a.setMessage('Please run this test on a device with a camera');
}
else
{
a.setMessage('Unexpected error: ' + error.code);
}
a.show();
}
});
/*********************************************************************
** Testing to make sure that I can actually create the button **
*********************************************************************/
Titanium.UI.setBackgroundColor('#000');
var cameraWindow = Titanium.UI.createWindow({
backgroundColor:'#FFF'
});
var startVideoButton = Titanium.UI.createButton({
bottom:10, width:120, height:40,
title:'Start Video'
});
var overlay = Titanium.UI.createView();
overlay.add(startVideoButton);
cameraWindow.add(overlay);
cameraWindow.open();
//This does what you would expect it to do. Show a window with a simple button on it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment