opening another Android app in a 'new window&#

2019-02-07 14:05发布

This is a little involved, so bear with me.

I've got two Android apps - one built in Adobe Air (the 'launcher') and one downloaded from the google play store (the 'target.') At a certain point I want the 'launcher' to open the 'target' and switch to it. Currently I'm doing this via the 'intent' protocol, like so:

navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=com.magix.camera_mx/com.magix.android.cameramx.main.MainMenu;end'));

... and it works, but when the 'target' (CameraMX in this example) opens, it uses the same 'window' as the 'launcher' app. Here's two screenshots, before and after opening the 'target:'

launcher alone

target taking over launcher's window

That's inconvenient, but I could put up with it if it was consistent. However, when I try the exact same process, only launching an arbitrary other app like Kingsoft Office:

navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=cn.wps.moffice_eng/cn.wps.moffice.documentmanager.PreStartActivity;end'));

The 'target' and 'launcher' exist as nice separate windows.

target opening in its own window, leaving the launcher alone

Why is that? What dictates whether an app comes up as a separate window, or reuses the current one? I've tried it with a handful - notably SoulCraft and Starchart launch in a new windows, but mostly the others all reuse the current window.

Is that something I have control over from within my air app? What's going on here?

2条回答
贼婆χ
2楼-- · 2019-02-07 14:17

The difference between your two scenarios (scenario 1 remains in a single task, scenario 2 starts a new task) is due to each "target" app's intent-filter manifest definition.

If you do not require a result from the Intent you can add flags (http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK) like below:

navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.magix.camera_mx/com.magix.android.cameramx.main.MainMenu;end'));
查看更多
乱世女痞
3楼-- · 2019-02-07 14:39

What you're calling a "window" is referred to in Android as a "task". You should be able to force the target application to open in a new task by setting appropriate flags, namely FLAG_ACTIVITY_NEW_TASK (note the launchFlags=0x10000000):

intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=<your-package-name>/.<your-activity-name>;end
查看更多
登录 后发表回答