Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25867] Android: Running an application through CLI flickers it's main activity at launch.

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-06-07T02:39:35.000+0000
Affected Version/sRelease 6.3.0, Release 7.1.0, Release 7.0.2
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsn/a
ReporterYordan Banev
AssigneeYordan Banev
Created2018-03-14T17:06:12.000+0000
Updated2018-06-28T22:18:23.000+0000

Description

Starting an Android application with 'appc run' or 'ti build' causes it to flicker at start when the main activity is launched. Launching afterwards from the device works just fine.

Comments

  1. Yordan Banev 2018-03-14

    PR: https://github.com/appcelerator/node-titanium-sdk/pull/26
  2. Yordan Banev 2018-03-16

    titanium-mobile PR: https://github.com/appcelerator/titanium_mobile/pull/9938
  3. Joshua Quick 2018-06-05

    [~ybanev], removing the "-n" parameter triggers our "Restart Required" dialog on app startup and it gets stuck in an infinite loop displaying this dialog. This happens to me on a real Pixel XL device. Note that not all devices exhibit this behavior, but it shows that the default intent handling is not the same across all devices and we should be explicit. I think a better solution would be to keep the "-n" parameter (it is needed to specify the package/activity name)... and also provide intent parameters action "MAIN" and category "LAUNCHER" so that we'll correctly simulate an app launch from the app menu. For example:
       ./adb shell am start -n com.appcelerator.testing/.ClassicapptestActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
       
    I'll write up a PR since what I'm doing solves another problem as well. _Edit: Added "-f 0x10200000" intent flags parameter which sets FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_RESET_TASK_IF_NEEDED. I've verified that these flags are set when launch from the app menu on the newest Android OS versions. Android 4.1 only sets the FLAG_ACTIVITY_NEW_TASK flag, but adding the 2nd flag is harmless for that version._
  4. Chris Barber 2018-06-05

    [~jquick] I checked it and it seemed that the -n flag had no effect. Both running the command's help and the docs do not indicate that the -n flag does anything: https://developer.android.com/studio/command-line/adb#am.
  5. Joshua Quick 2018-06-05

    [~cbarber], Just updated my comment. It happens to me on a real Pixel XL device. Not all devices have this behavior though. I'm going to go ahead with my changes since those extra arguments is how Android Studio does it.
  6. Joshua Quick 2018-06-05

    Also, the -n flag is used to specify the component name for the intent as documented here... https://developer.android.com/studio/command-line/adb#IntentSpec I agree that the way Google documents it in the link below doesn't make it clear, but in start [options] intent, the intent part takes the intent arguments in the link above. https://developer.android.com/studio/command-line/adb#am Case-in-point, I can do the following to show our website via the default web browser app...
       ./adb shell am start -a android.intent.action.VIEW -d https://www.appcelerator.com
       
    Developers sometimes do stuff like the above to easily test their app's intent-filter handling, such as with customer URL schemes.
  7. Lokesh Choudhary 2018-06-28

    Verified the fix in SDK 7.3.0.v20180628132121. Closing.

JSON Source