appc run launches the app on Android with an intent that is missing action "android.intent.action.MAIN" and category "android.intent.category.LAUNCHER", which is how an app is normally launched on Android via the app list screen.
Steps to reproduce:
- Build and run the below code on Android either via Appcelerator Studio or via appc run at the terminal.
- Wait for the app to be displayed on the Android device.
- Press the "Home" button to suspend the app. (Do NOT press the "Back" key.)
- From the home screen, go to the app list screen.
- Tap on the installed app to attempt to resume it.
On Android, an existing activity window stack can be resumed when using the same an intent that originally launched it. If given different intent settings for the same activity (such as the case here), then Android will create a new activity instance by default.
We need to modify the CLI on how it starts the app via Android "adb" command line tool here...
We need to add intent parameters -a to set the action, -c to set the category, and -f to set the flags via adb similar to the following.
The -f 0x10200000 part adds intent flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_RESET_TASK_IF_NEEDED. The FLAG_ACTIVITY_NEW_TASK is set by all Android OS versions when launching an app from the home screen. The FLAG_ACTIVITY_RESET_TASK_IF_NEEDED is set by newer Android OS versions (such as Android 8) but works fine on older OS versions such Android 4.1.
We also need this change to resolve a regression mentioned here: