Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created April 27, 2011 21:24
Show Gist options
  • Select an option

  • Save jonalter/945245 to your computer and use it in GitHub Desktop.

Select an option

Save jonalter/945245 to your computer and use it in GitHub Desktop.
Camera
Titanium.UI.setBackgroundColor('#000');
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var camera_button = Titanium.UI.createButton ({
title:'Camera',
height:60,
bottom: 10,
width:160
});
camera_button.addEventListener ('click', function(e) {
Titanium.Media.showCamera ({
saveToPhotoGallery: true,
allowEditing: true,
success: function(event){
var a = Titanium.UI.createAlertDialog({
title: 'You did it!'
});
a.show();
},
error: function(error){
var a = Titanium.UI.createAlertDialog({
title: 'Uh Oh...'
});
if (error.code == Titanium.Media.NO_CAMERA || error.code == Titanium.Media.NO_VIDEO) {
a.setMessage('Sorry, this device does not have a camera. You knew that, right?');
}
else {
a.setMessage('Unexpected error: ' + error.code);
}
a.show();
}
});
});
win1.add(camera_button);
win1.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment