# AppOpsManager.OnOpActiveChangedListener

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

# AppOpsManager.OnOpActiveChangedListener

*** ** * ** ***

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

`
public
static


interface
AppOpsManager.OnOpActiveChangedListener
`  
`


`

|-----------------------------------------------------|
| android.app.AppOpsManager.OnOpActiveChangedListener |

<br />

*** ** * ** ***

Callback for notification of changes to operation active state.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                          ||
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default void`  | ` `[onOpActiveChanged](https://developer.android.com/reference/android/app/AppOpsManager.OnOpActiveChangedListener#onOpActiveChanged(java.lang.String,%20int,%20java.lang.String,%20java.lang.String,%20int,%20boolean,%20int,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` op, int uid, `[String](https://developer.android.com/reference/java/lang/String)` packageName, `[String](https://developer.android.com/reference/java/lang/String)` attributionTag, int virtualDeviceId, boolean active, int attributionFlags, int attributionChainId) ` Similar to[ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int))](https://developer.android.com/), but also includes the virtual device id of the op is now active or inactive. |
| ` abstract void` | ` `[onOpActiveChanged](https://developer.android.com/reference/android/app/AppOpsManager.OnOpActiveChangedListener#onOpActiveChanged(java.lang.String,%20int,%20java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` op, int uid, `[String](https://developer.android.com/reference/java/lang/String)` packageName, boolean active) ` Called when the active state of an app-op changes.                                                                                                                                                                                                                                                                                                                                                                            |

## Public methods

### onOpActiveChanged

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

```
public void onOpActiveChanged (String op, 
                int uid, 
                String packageName, 
                String attributionTag, 
                int virtualDeviceId, 
                boolean active, 
                int attributionFlags, 
                int attributionChainId)
```

Similar to[ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int))](https://developer.android.com/), but also includes the virtual device id of the op is now active or inactive.

Implement this method if callbacks are required on all devices. If not implemented explicitly, the default implementation will notify for op state changes on the default device[Context.DEVICE_ID_DEFAULT](https://developer.android.com/reference/android/content/Context#DEVICE_ID_DEFAULT)only.

If implemented,[ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int))](https://developer.android.com/)will not be called automatically.

<br />

|                                                                                                                                                                  Parameters                                                                                                                                                                   ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `op`                 | `String`: The operation that changed. This value cannot be`null`. <br />                                                                                                                                                                                                                                                |
| `uid`                | `int`: The UID performing the operation. <br />                                                                                                                                                                                                                                                                         |
| `packageName`        | `String`: The package performing the operation. This value cannot be`null`. <br />                                                                                                                                                                                                                                      |
| `attributionTag`     | `String`: The operation's attribution tag. This value may be`null`. <br />                                                                                                                                                                                                                                              |
| `virtualDeviceId`    | `int`: the virtual device id whose operation has changed <br />                                                                                                                                                                                                                                                         |
| `active`             | `boolean`: Whether the operation became active or inactive. <br />                                                                                                                                                                                                                                                      |
| `attributionFlags`   | `int`: the attribution flags for this operation. Value is either`0`or a combination of android.app.AppOpsManager.ATTRIBUTION_FLAG_ACCESSOR, android.app.AppOpsManager.ATTRIBUTION_FLAG_INTERMEDIARY, android.app.AppOpsManager.ATTRIBUTION_FLAG_RECEIVER, and android.app.AppOpsManager.ATTRIBUTION_FLAG_TRUSTED <br /> |
| `attributionChainId` | `int`: the unique id of the attribution chain this op is a part of. <br />                                                                                                                                                                                                                                              |

### onOpActiveChanged

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

```
public abstract void onOpActiveChanged (String op, 
                int uid, 
                String packageName, 
                boolean active)
```

Called when the active state of an app-op changes.

<br />

|                                            Parameters                                             ||
|---------------|------------------------------------------------------------------------------------|
| `op`          | `String`: The operation that changed. This value cannot be`null`. <br />           |
| `uid`         | `int` <br />                                                                       |
| `packageName` | `String`: The package performing the operation. This value cannot be`null`. <br /> |
| `active`      | `boolean`: Whether the operation became active or inactive. <br />                 |