Application Launch Time is too long

from the CommonsWare Community archives

At June 5, 2019, 2:38pm, relaxedsoul asked:


I have a problem with the launch time of my application.

The main problem is in the following time interval:

Every time I click on the icon of the app, I see in the logs the following message
I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example/} from uid 2000
The time between this message and the following message from the custom application class the next line after super.onCreate(): 1.100 sec

So, After I click on the icon, it takes 1.100 sec to run the code in the CustomApplication class in the method “onCreate”.

When I click on the Slack icon, the application opens almost instantly.
I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.Slack/.ui.HomeActivity bnds=[586,2163][855,2408]} from uid 10052

I see the difference in the parameter flg. I am wondering, how I can reach the same speed of launch time?

Thank you!

At June 5, 2019, 3:05pm, mmurphy replied:

When I click on the Slack icon, the application opens almost instantly.

The process might already be running.

That flag appears to correspond to FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS. I do not work with Instant Apps, but given the name of the flag, I am not certain why a launcher would put it on a startActivity() call.

Do less work in your CustomApplication class, perhaps.

At June 5, 2019, 3:12pm, relaxedsoul replied:

Sorry for my question in the context I found out the answer by myself.

I checked - no, I removed the app from the TaskManager. If the app is in memory, I would see the last state.

I thought in the same direction, but it looked too difficult. I checked my different project with the simple app, and the flg is the same: 0x10200000

I wanted to decrease the time of launching the app even before the code from the app were performed.

The answer
I checked the theme of the activity I use. There was the following item:
<item name="android:windowDisablePreview">true</item>
It forced my first activity to be shown only after the ActivityManager is ready to start the Application.
It takes 1.1 second for ActivityManager to prepare. It is still very long time, but we decided to add Splash Screen and Now I can show it just right after the icon of the app is clicked.

I created the custom theme for the first activity, where the item is overridden to the value false
<item name="android:windowDisablePreview">false</item>

PS: the project is under my control for 2.5 years, but I still find here some crazy stuff.