Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26099

Android: CLI "appc run" should launch app with intent action MAIN category LAUNCHER


    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Story Points:
    • Sprint:
      2018 Sprint 12 SDK


      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.

      The consequence of this is that if you press the HOME button to suspend the app and then tap on the app from the home screen, then a new activity instance will be created and Titanium will be stuck on the splash screen since Titanium only supports running 1 JavaScript runtime at a time.

      Steps to reproduce:

      1. Build and run the below code on Android either via Appcelerator Studio or via appc run at the terminal.
      2. Wait for the app to be displayed on the Android device.
      3. Press the "Home" button to suspend the app. (Do NOT press the "Back" key.)
      4. From the home screen, go to the app list screen.
      5. Tap on the installed app to attempt to resume it.
      6. After doing this, notice that the app is stuck displaying the splash screen. It does not resume the app. It has created a new activity instance without a JavaScript runtime.

      var window = Ti.UI.createWindow();
      window.add(Ti.UI.createLabel({ text: 'Test' }));

      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.

      Recommended Solution:
      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.

      ./adb shell am start -n <PackageName>/.<ActivityName> -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000

      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: TIMOB-25867


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
                Yordan Banev
              • Watchers:
                1 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    Sync status:
                    Last received:
                    Last sent:

                    Git Integration