Search code examples
titaniumappcelerator

Take a screenshot in appcelerator and send it by email


How do I take a screenshot in appcelerator using a click event and send it using email? I have developed a floating action bar and want to associate a click event with it that takes a screenshot of the current screen and then opens an email dialog.

I tried the following:

$.btnScreen.addEventListener("click",function(e){ Ti.Media.takeScreenshot(function(){

Solution

  • I see you're calling the right method, but you're not actually capturing the blob. You should do something along these lines: (keep in mind, email dialog doesn't work in simulator)

    Ti.Media.takeScreenshot(function(blob){
        var dialog = Ti.UI.createEmailDialog();
        dialog.addAttachment(blob.media);
        dialog.open();
    });