Skip to content

Instantly share code, notes, and snippets.

@m1ga
Created February 22, 2021 10:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save m1ga/9bda79e73c4f602eabc021ff446a02af to your computer and use it in GitHub Desktop.
Save m1ga/9bda79e73c4f602eabc021ff446a02af to your computer and use it in GitHub Desktop.
Appcelerator Titanium - Share data with other apps #appcelerator #titanium #hyperloop
// share items e.g. String with other apps
if (OS_IOS) {
//
// Hyperloop for iOS
//
var UIActivityView = require('UIKit/UIActivityViewController')
var TiApp = require('Titanium/TiApp');
var uiv = UIActivityView.alloc().initWithActivityItemsApplicationActivities(["www.google.com"],null);
TiApp.app().showModalController(uiv, true);
} else {
//
// Intent for Android
//
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_SEND,
type : "text/plain"
});
intent.putExtra(Ti.Android.EXTRA_TEXT, "www.google.com");
intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
try {
Ti.Android.currentActivity.startActivity(intent);
} catch (ex) {
console.log("Error")
}
}
@caspahouzer
Copy link

I extended it for iPads modal windows

if (uiv.popoverPresentationController) {
    uiv.popoverPresentationController.sourceView = $.detail;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment