ApplicationStartInfo


public final class ApplicationStartInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.ApplicationStartInfo


Describes information related to an application process's startup.

Many aspects concerning why and how an applications process was started are valuable for apps both for logging and for potential behavior changes. Reason for process start, start type, start times, throttling, and other useful diagnostic data can be obtained from ApplicationStartInfo records.

ApplicationStartInfo objects can be retrieved via: - ActivityManager.getHistoricalProcessStartReasons, which can be called during or after a application's startup. Using this method, an app can retrieve information about an in-progress app start. - ActivityManager.addApplicationStartInfoCompletionListener, which returns an ApplicationStartInfo object via a callback when the startup is complete, or immediately if requested after the startup is complete.

Summary

Constants

int LAUNCH_MODE_SINGLE_INSTANCE

The system creates the activity at the root of a new task or locates the activity on an existing task with the same affinity.

int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

The activity can only be running as the root activity of the task, the first activity that created the task, and therefore there will only be one instance of this activity in a task; but activity can be instantiated multiple times in different tasks.

int LAUNCH_MODE_SINGLE_TASK

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance.

int LAUNCH_MODE_SINGLE_TOP

If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.

int LAUNCH_MODE_STANDARD

Default.

int STARTUP_STATE_ERROR

State indicating process startup has failed.

int STARTUP_STATE_FIRST_FRAME_DRAWN

State indicating process startup has made it to first frame draw.

int STARTUP_STATE_STARTED

State indicating process startup has started.

int START_COMPONENT_ACTIVITY

Process was started for an activity component.

int START_COMPONENT_BROADCAST

Process was started for a broadcast component.

int START_COMPONENT_CONTENT_PROVIDER

Process was started for a content provider component.

int START_COMPONENT_OTHER

Process was started not for one of the four standard components.

int START_COMPONENT_SERVICE

Process was started for a service component.

int START_REASON_ALARM

Process started due to alarm.

int START_REASON_BACKUP

Process started to run backup.

int START_REASON_BOOT_COMPLETE

Process started due to boot complete.

int START_REASON_BROADCAST

Process started due to broadcast received for any reason not explicitly listed.

int START_REASON_CONTENT_PROVIDER

Process started due to access of ContentProvider for any reason not explicitly listed.

int START_REASON_JOB

* Process started to run scheduled job.

int START_REASON_LAUNCHER

Process started due to click app icon or widget from launcher.

int START_REASON_LAUNCHER_RECENTS

Process started from launcher recents.

int START_REASON_OTHER

Process started not for any of the listed reasons.

int START_REASON_PUSH

Process started due to push message.

int START_REASON_SERVICE

Process started due to Service started for any reason not explicitly listed..

int START_REASON_START_ACTIVITY

Process started due to Activity started for any reason not explicitly listed.

int START_TIMESTAMP_APPLICATION_ONCREATE

Clock monotonic timestamp of Application onCreate called.

int START_TIMESTAMP_BIND_APPLICATION

Clock monotonic timestamp of bindApplication called.

int START_TIMESTAMP_FIRST_FRAME

Clock monotonic timestamp of first frame drawn.

int START_TIMESTAMP_FORK

Clock monotonic timestamp of process fork.

int START_TIMESTAMP_FULLY_DRAWN

Clock monotonic timestamp of reportFullyDrawn called by application.

int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

Clock monotonic timestamp of initial renderthread frame.

int START_TIMESTAMP_LAUNCH

Clock monotonic timestamp of launch started.

int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

The end of the range reserved for developer supplied timestamps.

int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

The beginning of the range reserved for developer supplied timestamps.

int START_TIMESTAMP_RESERVED_RANGE_SYSTEM

The end of the range, beginning with 0, reserved for system timestamps.

int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

Clock monotonic timestamp of surfaceflinger composition complete.

int START_TYPE_COLD

Process started from scratch.

int START_TYPE_HOT

Process brought back to foreground.

int START_TYPE_UNSET

Start type not yet set.

int START_TYPE_WARM

Process retained minimally SavedInstanceState.

Inherited constants

Fields

public static final Creator<ApplicationStartInfo> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getDefiningUid()

Return the defining kernel user identifier, maybe different from getRealUid() and getPackageUid(), if an external service has the android:useAppZygote set to true and was bound with the flag Context.BIND_EXTERNAL_SERVICE - in this case, this field here will be the kernel user identifier of the external service provider.

Intent getIntent()

The intent used to launch the application.

int getLaunchMode()

An instruction on how the activity should be launched.

int getPackageUid()

Similar to getRealUid(), it's the kernel user identifier that is assigned at the package installation time.

int getPid()

The process id.

String getProcessName()

The actual process name it was running with.

int getRealUid()

The kernel user identifier of the process, most of the time the system uses this to do access control checks.

int getReason()

The reason code of what triggered the process's start.

int getStartComponent()

The component type that was being started which triggered the start.

int getStartType()

The state of the app at startup.

int getStartupState()

Current state of startup.

Map<IntegerLong> getStartupTimestamps()

Various clock monotonic timestamps in nanoseconds throughout the startup process.

int hashCode()

Returns a hash code value for the object.

boolean wasForceStopped()

Informs whether this is the first process launch for an app since it was force-stopped for some reason.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

LAUNCH_MODE_SINGLE_INSTANCE

Added in API level 35
public static final int LAUNCH_MODE_SINGLE_INSTANCE

The system creates the activity at the root of a new task or locates the activity on an existing task with the same affinity. If an instance of the activity already exists and is at the root of the task, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.

Constant Value: 2 (0x00000002)

LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

Added in API level 35
public static final int LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

The activity can only be running as the root activity of the task, the first activity that created the task, and therefore there will only be one instance of this activity in a task; but activity can be instantiated multiple times in different tasks.

Constant Value: 4 (0x00000004)

LAUNCH_MODE_SINGLE_TASK

Added in API level 35
public static final int LAUNCH_MODE_SINGLE_TASK

Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.

Constant Value: 3 (0x00000003)

LAUNCH_MODE_SINGLE_TOP

Added in API level 35
public static final int LAUNCH_MODE_SINGLE_TOP

If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.

Constant Value: 1 (0x00000001)

LAUNCH_MODE_STANDARD

Added in API level 35
public static final int LAUNCH_MODE_STANDARD

Default. The system always creates a new instance of the activity in the target task and routes the intent to it.

Constant Value: 0 (0x00000000)

STARTUP_STATE_ERROR

Added in API level 35
public static final int STARTUP_STATE_ERROR

State indicating process startup has failed. Startup information in ApplicationStartInfo is incomplete, but no more will be added.

Constant Value: 1 (0x00000001)

STARTUP_STATE_FIRST_FRAME_DRAWN

Added in API level 35
public static final int STARTUP_STATE_FIRST_FRAME_DRAWN

State indicating process startup has made it to first frame draw. Startup information in ApplicationStartInfo is complete with potential exception of fully drawn timestamp which is not guaranteed to be set.

Constant Value: 2 (0x00000002)

STARTUP_STATE_STARTED

Added in API level 35
public static final int STARTUP_STATE_STARTED

State indicating process startup has started. Some information is available in ApplicationStartInfo and more will be added.

Constant Value: 0 (0x00000000)

START_COMPONENT_ACTIVITY

public static final int START_COMPONENT_ACTIVITY

Process was started for an activity component.

Constant Value: 1 (0x00000001)

START_COMPONENT_BROADCAST

public static final int START_COMPONENT_BROADCAST

Process was started for a broadcast component.

Constant Value: 2 (0x00000002)

START_COMPONENT_CONTENT_PROVIDER

public static final int START_COMPONENT_CONTENT_PROVIDER

Process was started for a content provider component.

Constant Value: 3 (0x00000003)

START_COMPONENT_OTHER

public static final int START_COMPONENT_OTHER

Process was started not for one of the four standard components.

Constant Value: 5 (0x00000005)

START_COMPONENT_SERVICE

public static final int START_COMPONENT_SERVICE

Process was started for a service component.

Constant Value: 4 (0x00000004)

START_REASON_ALARM

Added in API level 35
public static final int START_REASON_ALARM

Process started due to alarm.

Constant Value: 0 (0x00000000)

START_REASON_BACKUP

Added in API level 35
public static final int START_REASON_BACKUP

Process started to run backup.

Constant Value: 1 (0x00000001)

START_REASON_BOOT_COMPLETE

Added in API level 35
public static final int START_REASON_BOOT_COMPLETE

Process started due to boot complete.

Constant Value: 2 (0x00000002)

START_REASON_BROADCAST

Added in API level 35
public static final int START_REASON_BROADCAST

Process started due to broadcast received for any reason not explicitly listed.

Constant Value: 3 (0x00000003)

START_REASON_CONTENT_PROVIDER

Added in API level 35
public static final int START_REASON_CONTENT_PROVIDER

Process started due to access of ContentProvider for any reason not explicitly listed.

Constant Value: 4 (0x00000004)

START_REASON_JOB

Added in API level 35
public static final int START_REASON_JOB

* Process started to run scheduled job.

Constant Value: 5 (0x00000005)

START_REASON_LAUNCHER

Added in API level 35
public static final int START_REASON_LAUNCHER

Process started due to click app icon or widget from launcher.

Constant Value: 6 (0x00000006)

START_REASON_LAUNCHER_RECENTS

Added in API level 35
public static final int START_REASON_LAUNCHER_RECENTS

Process started from launcher recents.

Constant Value: 7 (0x00000007)

START_REASON_OTHER

Added in API level 35
public static final int START_REASON_OTHER

Process started not for any of the listed reasons.

Constant Value: 8 (0x00000008)

START_REASON_PUSH

Added in API level 35
public static final int START_REASON_PUSH

Process started due to push message.

Constant Value: 9 (0x00000009)

START_REASON_SERVICE

Added in API level 35
public static final int START_REASON_SERVICE

Process started due to Service started for any reason not explicitly listed..

Constant Value: 10 (0x0000000a)

START_REASON_START_ACTIVITY

Added in API level 35
public static final int START_REASON_START_ACTIVITY

Process started due to Activity started for any reason not explicitly listed.

Constant Value: 11 (0x0000000b)

START_TIMESTAMP_APPLICATION_ONCREATE

Added in API level 35
public static final int START_TIMESTAMP_APPLICATION_ONCREATE

Clock monotonic timestamp of Application onCreate called.

Constant Value: 2 (0x00000002)

START_TIMESTAMP_BIND_APPLICATION

Added in API level 35
public static final int START_TIMESTAMP_BIND_APPLICATION

Clock monotonic timestamp of bindApplication called.

Constant Value: 3 (0x00000003)

START_TIMESTAMP_FIRST_FRAME

Added in API level 35
public static final int START_TIMESTAMP_FIRST_FRAME

Clock monotonic timestamp of first frame drawn.

Constant Value: 4 (0x00000004)

START_TIMESTAMP_FORK

Added in API level 35
public static final int START_TIMESTAMP_FORK

Clock monotonic timestamp of process fork.

Constant Value: 1 (0x00000001)

START_TIMESTAMP_FULLY_DRAWN

Added in API level 35
public static final int START_TIMESTAMP_FULLY_DRAWN

Clock monotonic timestamp of reportFullyDrawn called by application.

Constant Value: 5 (0x00000005)

START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

Added in API level 35
public static final int START_TIMESTAMP_INITIAL_RENDERTHREAD_FRAME

Clock monotonic timestamp of initial renderthread frame.

Constant Value: 6 (0x00000006)

START_TIMESTAMP_LAUNCH

Added in API level 35
public static final int START_TIMESTAMP_LAUNCH

Clock monotonic timestamp of launch started.

Constant Value: 0 (0x00000000)

START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

Added in API level 35
public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER

The end of the range reserved for developer supplied timestamps.

Constant Value: 30 (0x0000001e)

START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

Added in API level 35
public static final int START_TIMESTAMP_RESERVED_RANGE_DEVELOPER_START

The beginning of the range reserved for developer supplied timestamps.

Constant Value: 21 (0x00000015)

START_TIMESTAMP_RESERVED_RANGE_SYSTEM

Added in API level 35
public static final int START_TIMESTAMP_RESERVED_RANGE_SYSTEM

The end of the range, beginning with 0, reserved for system timestamps.

Constant Value: 20 (0x00000014)

START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

Added in API level 35
public static final int START_TIMESTAMP_SURFACEFLINGER_COMPOSITION_COMPLETE

Clock monotonic timestamp of surfaceflinger composition complete.

Constant Value: 7 (0x00000007)

START_TYPE_COLD

Added in API level 35
public static final int START_TYPE_COLD

Process started from scratch.

Constant Value: 1 (0x00000001)

START_TYPE_HOT

Added in API level 35
public static final int START_TYPE_HOT

Process brought back to foreground.

Constant Value: 3 (0x00000003)

START_TYPE_UNSET

Added in API level 35
public static final int START_TYPE_UNSET

Start type not yet set.

Constant Value: 0 (0x00000000)

START_TYPE_WARM

Added in API level 35
public static final int START_TYPE_WARM

Process retained minimally SavedInstanceState.

Constant Value: 2 (0x00000002)

Fields

CREATOR

Added in API level 35
public static final Creator<ApplicationStartInfo> CREATOR

Public methods

describeContents

Added in API level 35
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getDefiningUid

Added in API level 35
public int getDefiningUid ()

Return the defining kernel user identifier, maybe different from getRealUid() and getPackageUid(), if an external service has the android:useAppZygote set to true and was bound with the flag Context.BIND_EXTERNAL_SERVICE - in this case, this field here will be the kernel user identifier of the external service provider.

Note: field will be set for any getStartupState() value.

Returns
int

getIntent

Added in API level 35
public Intent getIntent ()

The intent used to launch the application.

Note: Intent is stripped and does not include extras.

Note: field will be set for any getStartupState() value.

Returns
Intent This value may be null.

getLaunchMode

Added in API level 35
public int getLaunchMode ()

An instruction on how the activity should be launched. There are five modes that work in conjunction with activity flags in Intent objects to determine what should happen when the activity is called upon to handle an intent. Modes: LAUNCH_MODE_STANDARD LAUNCH_MODE_SINGLE_TOP LAUNCH_MODE_SINGLE_INSTANCE LAUNCH_MODE_SINGLE_TASK LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

Note: field will be set for any getStartupState() value.

Returns
int Value is LAUNCH_MODE_STANDARD, LAUNCH_MODE_SINGLE_TOP, LAUNCH_MODE_SINGLE_INSTANCE, LAUNCH_MODE_SINGLE_TASK, or LAUNCH_MODE_SINGLE_INSTANCE_PER_TASK

getPackageUid

Added in API level 35
public int getPackageUid ()

Similar to getRealUid(), it's the kernel user identifier that is assigned at the package installation time.

Note: field will be set for any getStartupState() value.

Returns
int

getPid

Added in API level 35
public int getPid ()

The process id.

Note: field will be set for any getStartupState() value.

Returns
int

getProcessName

Added in API level 35
public String getProcessName ()

The actual process name it was running with.

Note: field will be set for any getStartupState() value.

Returns
String This value cannot be null.

getRealUid

Added in API level 35
public int getRealUid ()

The kernel user identifier of the process, most of the time the system uses this to do access control checks. It's typically the uid of the package where the component is running from, except the case of isolated process, where this field identifies the kernel user identifier that this process is actually running with, while the getPackageUid() identifies the kernel user identifier that is assigned at the package installation time.

Note: field will be set for any getStartupState() value.

Returns
int

getReason

Added in API level 35
public int getReason ()

The reason code of what triggered the process's start. Start reason provides granular reasoning on why the app is being started. Start reason should not be used for distinguishing between the component the app is being started for as some reasons may overlap with multiple components, see getStartComponent() for this functionality instead.

Note: field will be set for any getStartupState() value.

Returns
int Value is START_REASON_ALARM, START_REASON_BACKUP, START_REASON_BOOT_COMPLETE, START_REASON_BROADCAST, START_REASON_CONTENT_PROVIDER, START_REASON_JOB, START_REASON_LAUNCHER, START_REASON_LAUNCHER_RECENTS, START_REASON_OTHER, START_REASON_PUSH, START_REASON_SERVICE, or START_REASON_START_ACTIVITY

getStartComponent

public int getStartComponent ()

The component type that was being started which triggered the start. Start component should be used to accurately distinguish between the 4 component types: activity, service, broadcast, and content provider. This can be useful for optimizing startup flow by enabling the caller to only load the necessary dependencies for a specific component type. For more granular information on why the app is being started, see getReason().

Note: field will be set for any getStartupState() value.

Returns
int Value is START_COMPONENT_ACTIVITY, START_COMPONENT_BROADCAST, START_COMPONENT_CONTENT_PROVIDER, START_COMPONENT_SERVICE, or START_COMPONENT_OTHER

getStartType

Added in API level 35
public int getStartType ()

The state of the app at startup.

Note: field will be set for getStartupState() value STARTUP_STATE_FIRST_FRAME_DRAWN. Not guaranteed for other states.

Returns
int Value is START_TYPE_UNSET, START_TYPE_COLD, START_TYPE_WARM, or START_TYPE_HOT

getStartupState

Added in API level 35
public int getStartupState ()

Current state of startup. Can be used to determine whether the object will have additional fields added as it may be queried before all data is collected.

Note: field will always be set and available.

Returns
int Value is STARTUP_STATE_STARTED, STARTUP_STATE_ERROR, or STARTUP_STATE_FIRST_FRAME_DRAWN

getStartupTimestamps

Added in API level 35
public Map<IntegerLong> getStartupTimestamps ()

Various clock monotonic timestamps in nanoseconds throughout the startup process.

Note: different timestamps will be available for different values of getStartupState(): (Subsequent rows contain all timestamps of proceding states.) For STARTUP_STATE_STARTED, timestamp START_TIMESTAMP_LAUNCH will be available. For STARTUP_STATE_ERROR, no additional timestamps are guaranteed available. For STARTUP_STATE_FIRST_FRAME_DRAWN, timestamps START_TIMESTAMP_APPLICATION_ONCREATE, START_TIMESTAMP_BIND_APPLICATION, and START_TIMESTAMP_FIRST_FRAME will additionally be available. Timestamp START_TIMESTAMP_FULLY_DRAWN is never guaranteed to be available as it is dependant on devloper calling Activity.reportFullyDrawn.

Returns
Map<IntegerLong> This value cannot be null.

hashCode

Added in API level 35
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

Returns
int a hash code value for this object.

wasForceStopped

Added in API level 35
public boolean wasForceStopped ()

Informs whether this is the first process launch for an app since it was force-stopped for some reason. This allows the app to know if it should re-register for any alarms, jobs and other callbacks that were cleared when the app was force-stopped.

Returns
boolean true if this is the first process launch of the app after having been stopped, false otherwise.

writeToParcel

Added in API level 35
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES