Created
May 1, 2019 08:57
-
-
Save drauggres/e66727185b783daadeee10efb22b66aa to your computer and use it in GitHub Desktop.
Titanium. Display a PNG file via an intent and external app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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