# ProfilingTrigger

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/os/ProfilingTrigger#nestedclasses)\|[Constants](https://developer.android.com/reference/android/os/ProfilingTrigger#constants)\|[Methods](https://developer.android.com/reference/android/os/ProfilingTrigger#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/os/ProfilingTrigger#inhmethods)  

# ProfilingTrigger

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/ProfilingTrigger "View this page in Kotlin")\|Java

`
public

final

class
ProfilingTrigger
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.ProfilingTrigger |

<br />

*** ** * ** ***

Encapsulates a single profiling trigger.

## Summary

|                                                                                                            ### Nested classes                                                                                                             ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [ProfilingTrigger.Builder](https://developer.android.com/reference/android/os/ProfilingTrigger.Builder) Builder class to create a[ProfilingTrigger](https://developer.android.com/reference/android/os/ProfilingTrigger)object. |

|                                                                                                                                                                                                ### Constants                                                                                                                                                                                                ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [TRIGGER_TYPE_ANR](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_ANR) Trigger occurs after an ANR has been identified, but before the system would attempt to kill the app.                                                                                                                                                                                       |
| `int` | [TRIGGER_TYPE_APP_FULLY_DRAWN](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_APP_FULLY_DRAWN) Trigger occurs after[Activity.reportFullyDrawn()](https://developer.android.com/reference/android/app/Activity#reportFullyDrawn())is called for a cold start.                                                                                                       |
| `int` | [TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE) Trigger occurs when an app requests the actively running trace by calling[ProfilingManager.requestRunningSystemTrace(String)](https://developer.android.com/reference/android/os/ProfilingManager#requestRunningSystemTrace(java.lang.String)). |
| `int` | [TRIGGER_TYPE_KILL_FORCE_STOP](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_FORCE_STOP) Trigger occurs when an app is killed due to the user clicking the "Force stop" button of the App info page in Settings.                                                                                                                                             |
| `int` | [TRIGGER_TYPE_KILL_RECENTS](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_RECENTS) Trigger occurs when an app is killed due to the user removing it in the[Recents screen](https://developer.android.com/guide/components/activities/recents).                                                                                                               |
| `int` | [TRIGGER_TYPE_KILL_TASK_MANAGER](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_TASK_MANAGER) Trigger occurs when an app is killed due to the user clicking the "Stop" button for the application in[Task Manager](https://developer.android.com/develop/background-work/services/fgs/handle-user-stopping).                                                  |
| `int` | [TRIGGER_TYPE_NONE](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_NONE) No trigger.                                                                                                                                                                                                                                                                               |

|                                                                                          ### Public methods                                                                                           ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int` | ` `[getRateLimitingPeriodHours](https://developer.android.com/reference/android/os/ProfilingTrigger#getRateLimitingPeriodHours())`() ` The requester set rate limiting period in hours.       |
| ` int` | ` `[getTriggerType](https://developer.android.com/reference/android/os/ProfilingTrigger#getTriggerType())`() ` The trigger type indicates which event should trigger the requested profiling. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Constants

### TRIGGER_TYPE_ANR

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int TRIGGER_TYPE_ANR
```

Trigger occurs after an ANR has been identified, but before the system would attempt to kill the app. The trigger does not necessarily indicate that the app was killed due to the ANR.

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 2 (0x00000002)  

### TRIGGER_TYPE_APP_FULLY_DRAWN

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int TRIGGER_TYPE_APP_FULLY_DRAWN
```

Trigger occurs after[Activity.reportFullyDrawn()](https://developer.android.com/reference/android/app/Activity#reportFullyDrawn())is called for a cold start.

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 1 (0x00000001)  

### TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public static final int TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE
```

Trigger occurs when an app requests the actively running trace by calling[ProfilingManager.requestRunningSystemTrace(String)](https://developer.android.com/reference/android/os/ProfilingManager#requestRunningSystemTrace(java.lang.String)).

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 3 (0x00000003)  

### TRIGGER_TYPE_KILL_FORCE_STOP

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public static final int TRIGGER_TYPE_KILL_FORCE_STOP
```

Trigger occurs when an app is killed due to the user clicking the "Force stop" button of the App info page in Settings.

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 4 (0x00000004)  

### TRIGGER_TYPE_KILL_RECENTS

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public static final int TRIGGER_TYPE_KILL_RECENTS
```

Trigger occurs when an app is killed due to the user removing it in the[Recents screen](https://developer.android.com/guide/components/activities/recents).

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 5 (0x00000005)  

### TRIGGER_TYPE_KILL_TASK_MANAGER

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public static final int TRIGGER_TYPE_KILL_TASK_MANAGER
```

Trigger occurs when an app is killed due to the user clicking the "Stop" button for the application in[Task Manager](https://developer.android.com/develop/background-work/services/fgs/handle-user-stopping).

System will provide a snapshot of a running system trace in response to this trigger.

<br />

Constant Value: 6 (0x00000006)  

### TRIGGER_TYPE_NONE

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int TRIGGER_TYPE_NONE
```

No trigger. Used in[ProfilingResult](https://developer.android.com/reference/android/os/ProfilingResult)for non trigger caused results.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### getRateLimitingPeriodHours

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getRateLimitingPeriodHours ()
```

The requester set rate limiting period in hours.

The period is the minimum time the system should wait before providing another profiling result for the same trigger; actual time between events may be longer.

If the rate limiting period is set to 0, no app-provided rate limiting will be used.

This rate limiting is in addition to any system level rate limiting that may be applied.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getTriggerType

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getTriggerType ()
```

The trigger type indicates which event should trigger the requested profiling.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                               Returns                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | Value is[TRIGGER_TYPE_NONE](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_NONE),[TRIGGER_TYPE_APP_FULLY_DRAWN](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_APP_FULLY_DRAWN),[TRIGGER_TYPE_ANR](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_ANR),[TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_APP_REQUEST_RUNNING_TRACE),[TRIGGER_TYPE_KILL_FORCE_STOP](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_FORCE_STOP),[TRIGGER_TYPE_KILL_RECENTS](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_RECENTS), or[TRIGGER_TYPE_KILL_TASK_MANAGER](https://developer.android.com/reference/android/os/ProfilingTrigger#TRIGGER_TYPE_KILL_TASK_MANAGER) <br /> |