ApplicationExitInfo


public final class ApplicationExitInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.ApplicationExitInfo


Describes the information of an application process's death.

Application process could die for many reasons, for example REASON_LOW_MEMORY when it was killed by the system because it was running low on memory. Reason of the death can be retrieved via getReason(). Besides the reason, there are a few other auxiliary APIs like getStatus() and getImportance() to help the caller with additional diagnostic information.

Summary

Constants

int REASON_ANR

Application process was killed due to being unresponsive (ANR).

int REASON_CRASH

Application process died because of an unhandled exception in Java code.

int REASON_CRASH_NATIVE

Application process died because of a native code crash.

int REASON_DEPENDENCY_DIED

Application process was killed because its dependency was going away, for example, a stable content provider connection's client will be killed if the provider is killed.

int REASON_EXCESSIVE_RESOURCE_USAGE

Application process was killed by the system due to excessive resource usage.

int REASON_EXIT_SELF

Application process exit normally by itself, for example, via System.exit(int); getStatus() will specify the exit code.

int REASON_FREEZER

Application process was killed by App Freezer, for example, because it receives sync binder transactions while being frozen.

int REASON_INITIALIZATION_FAILURE

Application process was killed because of initialization failure, for example, it took too long to attach to the system during the start, or there was an error during initialization.

int REASON_LOW_MEMORY

Application process was killed by the system low memory killer, meaning the system was under memory pressure at the time of kill.

int REASON_OTHER

Application process was killed by the system for various other reasons which are not by problems in apps and not actionable by apps, for example, the system just finished updates; getDescription() will specify the cause given by the system.

int REASON_PACKAGE_STATE_CHANGE

Application process was killed because the app was disabled, or any of its component states have changed without PackageManager.DONT_KILL_APP

Prior to Build.VERSION_CODES.UPSIDE_DOWN_CAKE, REASON_USER_REQUESTED was used to indicate that an app was updated.

int REASON_PACKAGE_UPDATED

Application process was killed because it was updated.

int REASON_PERMISSION_CHANGE

Application process was killed due to a runtime permission change.

int REASON_SIGNALED

Application process died due to the result of an OS signal; for example, OsConstants.SIGKILL; getStatus() will specify the signal number.

int REASON_UNKNOWN

Application process died due to unknown reason.

int REASON_USER_REQUESTED

Application process was killed because of the user request, for example, user clicked the "Force stop" button of the application in the Settings, or removed the application away from Recents.

int REASON_USER_STOPPED

Application process was killed, because the user it is running as on devices with mutlple users, was stopped.

Inherited constants

Fields

public static final Creator<ApplicationExitInfo> CREATOR

Public methods

int describeContents()

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

boolean equals(Object other)

Indicates whether some other object is "equal to" this one.

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.

String getDescription()

The human readable description of the process's death, given by the system; could be null.

int getImportance()

The importance of the process that it used to have before the death.

int getPackageUid()

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

int getPid()

The process id of the process that died.

String getProcessName()

The actual process name it was running with.

byte[] getProcessStateSummary()

Return the state data set by calling ActivityManager.setProcessStateSummary(byte[]) from the process before its death.

long getPss()

Last proportional set size of the memory that the process had used in kB.

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 the process's death.

long getRss()

Last resident set size of the memory that the process had used in kB.

int getStatus()

The exit status argument of exit() if the application calls it, or the signal number if the application is signaled.

long getTimestamp()

The timestamp of the process's death, in milliseconds since the epoch, as returned by System.currentTimeMillis().

InputStream getTraceInputStream()

Return the InputStream to the traces that was taken by the system prior to the death of the process; typically it'll be available when the reason is REASON_ANR, though if the process gets an ANR but recovers, and dies for another reason later, this trace will be included in the record of ApplicationExitInfo still.

UserHandle getUserHandle()

Return the user id of the record on a multi-user system.

int hashCode()

Returns a hash code value for the object.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

REASON_ANR

Added in API level 30
public static final int REASON_ANR

Application process was killed due to being unresponsive (ANR).

Constant Value: 6 (0x00000006)

REASON_CRASH

Added in API level 30
public static final int REASON_CRASH

Application process died because of an unhandled exception in Java code.

Constant Value: 4 (0x00000004)

REASON_CRASH_NATIVE

Added in API level 30
public static final int REASON_CRASH_NATIVE

Application process died because of a native code crash.

Constant Value: 5 (0x00000005)

REASON_DEPENDENCY_DIED

Added in API level 30
public static final int REASON_DEPENDENCY_DIED

Application process was killed because its dependency was going away, for example, a stable content provider connection's client will be killed if the provider is killed.

Constant Value: 12 (0x0000000c)

REASON_EXCESSIVE_RESOURCE_USAGE

Added in API level 30
public static final int REASON_EXCESSIVE_RESOURCE_USAGE

Application process was killed by the system due to excessive resource usage.

Constant Value: 9 (0x00000009)

REASON_EXIT_SELF

Added in API level 30
public static final int REASON_EXIT_SELF

Application process exit normally by itself, for example, via System.exit(int); getStatus() will specify the exit code.

Applications should normally not do this, as the system has a better knowledge in terms of process management.

Constant Value: 1 (0x00000001)

REASON_FREEZER

Added in API level 33
public static final int REASON_FREEZER

Application process was killed by App Freezer, for example, because it receives sync binder transactions while being frozen.

Constant Value: 14 (0x0000000e)

REASON_INITIALIZATION_FAILURE

Added in API level 30
public static final int REASON_INITIALIZATION_FAILURE

Application process was killed because of initialization failure, for example, it took too long to attach to the system during the start, or there was an error during initialization.

Constant Value: 7 (0x00000007)

REASON_LOW_MEMORY

Added in API level 30
public static final int REASON_LOW_MEMORY

Application process was killed by the system low memory killer, meaning the system was under memory pressure at the time of kill.

Not all devices support reporting REASON_LOW_MEMORY; on a device with no such support, when a process is killed due to memory pressure, the getReason() will return REASON_SIGNALED and getStatus() will return the value OsConstants.SIGKILL. Application should use ActivityManager.isLowMemoryKillReportSupported() to check if the device supports reporting REASON_LOW_MEMORY or not.

Constant Value: 3 (0x00000003)

REASON_OTHER

Added in API level 30
public static final int REASON_OTHER

Application process was killed by the system for various other reasons which are not by problems in apps and not actionable by apps, for example, the system just finished updates; getDescription() will specify the cause given by the system.

Constant Value: 13 (0x0000000d)

REASON_PACKAGE_STATE_CHANGE

Added in API level 34
public static final int REASON_PACKAGE_STATE_CHANGE

Application process was killed because the app was disabled, or any of its component states have changed without PackageManager.DONT_KILL_APP

Prior to Build.VERSION_CODES.UPSIDE_DOWN_CAKE, REASON_USER_REQUESTED was used to indicate that an app was updated.

Constant Value: 15 (0x0000000f)

REASON_PACKAGE_UPDATED

Added in API level 34
public static final int REASON_PACKAGE_UPDATED

Application process was killed because it was updated.

Prior to Build.VERSION_CODES.UPSIDE_DOWN_CAKE, REASON_USER_REQUESTED was used to indicate that an app was updated.

Constant Value: 16 (0x00000010)

REASON_PERMISSION_CHANGE

Added in API level 30
public static final int REASON_PERMISSION_CHANGE

Application process was killed due to a runtime permission change.

Constant Value: 8 (0x00000008)

REASON_SIGNALED

Added in API level 30
public static final int REASON_SIGNALED

Application process died due to the result of an OS signal; for example, OsConstants.SIGKILL; getStatus() will specify the signal number.

Constant Value: 2 (0x00000002)

REASON_UNKNOWN

Added in API level 30
public static final int REASON_UNKNOWN

Application process died due to unknown reason.

Constant Value: 0 (0x00000000)

REASON_USER_REQUESTED

Added in API level 30
public static final int REASON_USER_REQUESTED

Application process was killed because of the user request, for example, user clicked the "Force stop" button of the application in the Settings, or removed the application away from Recents.

Prior to Build.VERSION_CODES.UPSIDE_DOWN_CAKE, one of the uses of this reason was to indicate that an app was killed due to it being updated or any of its component states have changed without PackageManager.DONT_KILL_APP

Constant Value: 10 (0x0000000a)

REASON_USER_STOPPED

Added in API level 30
public static final int REASON_USER_STOPPED

Application process was killed, because the user it is running as on devices with mutlple users, was stopped.

Constant Value: 11 (0x0000000b)

Fields

CREATOR

Added in API level 30
public static final Creator<ApplicationExitInfo> CREATOR

Public methods

describeContents

Added in API level 30
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

equals

Added in API level 30
public boolean equals (Object other)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other Object: This value may be null.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getDefiningUid

Added in API level 30
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.

Returns
int

getDescription

Added in API level 30
public String getDescription ()

The human readable description of the process's death, given by the system; could be null.

Note: only intended to be human-readable and the system provides no guarantees that the format is stable across devices or Android releases.

Returns
String

getPackageUid

Added in API level 30
public int getPackageUid ()

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

Returns
int

getPid

Added in API level 30
public int getPid ()

The process id of the process that died.

Returns
int

getProcessName

Added in API level 30
public String getProcessName ()

The actual process name it was running with.

Returns
String This value cannot be null.

getProcessStateSummary

Added in API level 30
public byte[] getProcessStateSummary ()

Return the state data set by calling ActivityManager.setProcessStateSummary(byte[]) from the process before its death.

Returns
byte[] The process-customized data This value may be null.

getPss

Added in API level 30
public long getPss ()

Last proportional set size of the memory that the process had used in kB.

Note: This is the value from last sampling on the process, it's NOT the exact memory information prior to its death; and it'll be zero if the process died before system had a chance to take the sample.

Returns
long

getRealUid

Added in API level 30
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.

Returns
int

getRss

Added in API level 30
public long getRss ()

Last resident set size of the memory that the process had used in kB.

Note: This is the value from last sampling on the process, it's NOT the exact memory information prior to its death; and it'll be zero if the process died before system had a chance to take the sample.

Returns
long

getStatus

Added in API level 30
public int getStatus ()

The exit status argument of exit() if the application calls it, or the signal number if the application is signaled.

Returns
int

getTimestamp

Added in API level 30
public long getTimestamp ()

The timestamp of the process's death, in milliseconds since the epoch, as returned by System.currentTimeMillis().
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

Returns
long Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

getTraceInputStream

Added in API level 30
public InputStream getTraceInputStream ()

Return the InputStream to the traces that was taken by the system prior to the death of the process; typically it'll be available when the reason is REASON_ANR, though if the process gets an ANR but recovers, and dies for another reason later, this trace will be included in the record of ApplicationExitInfo still. Beginning with API 31, tombstone traces will be returned for REASON_CRASH_NATIVE, with an InputStream containing a protobuf with this schema. Note that because these traces are kept in a separate global circular buffer, crashes may be overwritten by newer crashes (including from other applications), so this may still return null.

Returns
InputStream The input stream to the traces that was taken by the system prior to the death of the process.

Throws
IOException

getUserHandle

Added in API level 30
public UserHandle getUserHandle ()

Return the user id of the record on a multi-user system.

Returns
UserHandle This value cannot be null.

hashCode

Added in API level 30
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.

toString

Added in API level 30
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 30
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