Skip to content

Instantly share code, notes, and snippets.

@drauggres
Created May 1, 2019 08:57
Show Gist options
  • Save drauggres/e66727185b783daadeee10efb22b66aa to your computer and use it in GitHub Desktop.
Save drauggres/e66727185b783daadeee10efb22b66aa to your computer and use it in GitHub Desktop.
Titanium. Display a PNG file via an intent and external app
var window = Ti.UI.createWindow();
var button = Ti.UI.createButton({
title: "Send Intent",
});
button.addEventListener("click", function(e){
button.toImage(function(imageBlob) {
if (!imageBlob) {
return;
}
var targetFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "image.png");
targetFile.write(imageBlob, false);
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
data: targetFile.nativePath,
type: "image/png",
});
intent = Ti.Android.createIntentChooser(intent, "Choose");
Ti.Android.currentActivity.startActivity(intent);
});
});
window.add(button);
window.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment