Created
January 23, 2019 16:02
-
-
Save MotiurRahman/9d0636134d348b9ba3cb6c91b65f6c49 to your computer and use it in GitHub Desktop.
Open Titanium app through intent.
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
/** | |
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(); |
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
/** | |
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