Skip to content

Instantly share code, notes, and snippets.

@ihsanberahim
Created October 25, 2013 04:50
Show Gist options
  • Save ihsanberahim/7149561 to your computer and use it in GitHub Desktop.
Save ihsanberahim/7149561 to your computer and use it in GitHub Desktop.
email screenshot
/*
* For beta testing purposes create a camera button that can be set
* as the right nav button. Upon clicking create a screenshot and
* display the email dialog with pre-populated fields.
* This is a convenience for testers to send a screenshot straight
* out of the applicaiton.
*/
function createScreenShotButton() {
var buttonObjects = [
{image:'images/camera.png', width:45}
];
var buttonBar = Titanium.UI.createButtonBar({
labels:buttonObjects,
backgroundColor:'#000'
});
var indicator = createIndicatorWindow();
buttonBar.addEventListener('click', function(e) {
if (e.index === 0) {
Ti.Media.takeScreenshot(function(event) {
indicator.openIndicator();
var emailDialog = Ti.UI.createEmailDialog()
emailDialog.subject = "Screenshot from myApp";
emailDialog.toRecipients = ['my@email-address.com'];
emailDialog.messageBody = 'Describe the problem please';
emailDialog.addAttachment(event.media);
emailDialog.open();
indicator.closeIndicator();
});
}
});
return buttonBar;
}
exports.createScreenShotButton = createScreenShotButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment