Skip to content

Instantly share code, notes, and snippets.

@MotiurRahman
Created January 23, 2019 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MotiurRahman/9d0636134d348b9ba3cb6c91b65f6c49 to your computer and use it in GitHub Desktop.
Save MotiurRahman/9d0636134d348b9ba3cb6c91b65f6c49 to your computer and use it in GitHub Desktop.
Open Titanium app through intent.
/**
app.js file for target App.
*/
var win = Ti.UI.createWindow();
/*Ti.Android.currentActivity.addEventListener('newintent', function(e){
alert('onNewIntent');
});*/
// Create a Button.
var open = Ti.UI.createButton({
title : "Open Source Win",
height : 100,
width : Ti.UI.SIZE,
color: "black",
top : 50
});
open.addEventListener("click", function(e) {
var activity = Ti.Android.currentActivity;
// var launcherActivity = (new Activity(activity));
// var packageManager = launcherActivity.getPackageManager();
// var launchIntent = packageManager.getLaunchIntentForPackage(APP_B_PACKAGE_NAME);
//
// if (launchIntent!=null) {
//
// } else {
//
// alert("App A not isntalled");
// }
var intent = Ti.Android.createIntent({
className : "com.bd.source.SourceappActivity",
packageName : "com.bd.source"
});
intent.addFlags(Ti.Android.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intent.addFlags(Ti.Android.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Ti.Android.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
activity.startActivity(intent);
});
win.add(open);
win.open();
/**
app.js file for source App
*/
var win = Ti.UI.createWindow({
backgroundColor : "white"
});
// Create a Button.
var open = Ti.UI.createButton({
title : "Open Target Win",
height : 100,
width : Ti.UI.SIZE,
color : "black",
top : 50
});
open.addEventListener('click', function(e) {
var activity = Ti.Android.currentActivity;
// var launcherActivity = (new Activity(activity));
// var packageManager = launcherActivity.getPackageManager();
// var launchIntent = packageManager.getLaunchIntentForPackage(APP_B_PACKAGE_NAME);
//
// if (launchIntent!=null) {
//
// } else {
//
// alert("App B not installed");
// }
var intent = Ti.Android.createIntent({
className : "com.bd.target.TargetappActivity",
packageName : "com.bd.target"
});
intent.addFlags(Ti.Android.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intent.addFlags(Ti.Android.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Ti.Android.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
activity.startActivity(intent);
});
win.add(open);
/**
* Open the tabGroup
*/
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment