Skip to content

Instantly share code, notes, and snippets.

@de1mat
Forked from m1ga/hyperloop.js
Created January 23, 2023 06:23
Show Gist options
  • Save de1mat/e0d8c1940173d42905597f9a70a36a23 to your computer and use it in GitHub Desktop.
Save de1mat/e0d8c1940173d42905597f9a70a36a23 to your computer and use it in GitHub Desktop.

Revisions

  1. @m1ga m1ga revised this gist Feb 22, 2021. No changes.
  2. @m1ga m1ga created this gist Feb 22, 2021.
    27 changes: 27 additions & 0 deletions hyperloop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // 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")
    }
    }