In Unity android application(called application A), you want to launch other android app(application B).
To open separate application, you need to use:
I had tried to follow some entries and try :
List<ApplicationInfo> packages = getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
if(packageNameToOpen.equals(packageInfo.packageName)){
try{
Intent intent = new Intent();
intent.putExtra(key, value);
intent.setComponent(new ComponentName(packageName,activityName));
UnityPlayer.currentActivity.startActivity(intent);
}catch(Exception e){
}
Android manages its items in "tasks" and "activity stack". If you normally call new activity as above, the activity of other app would be put in to same task of the current applications, which means you are not openning new application. You can see an example of opening mail client, the mail client allow you to call mail activity and it is put in to your current application's task.To open separate application, you need to use:
The right method:
<Note:> Need to add "singleInstance" launchmode to manifest of the new-app, in some case.
final PackageManager pm = UnityPlayer.currentActivity.getPackageManager();
Intent LaunchIntent = pm.getLaunchIntentForPackage(packageNameToOpen);
try{
LaunchIntent.putExtra(key, value);
UnityPlayer.currentActivity.startActivity(LaunchIntent);
}catch(Exception e){
}
Hope it helps
Comments
Post a Comment