Added in API level 30

AppOpsManager.OnOpActiveChangedListener


public static interface AppOpsManager.OnOpActiveChangedListener

android.app.AppOpsManager.OnOpActiveChangedListener


Callback for notification of changes to operation active state.

Summary

Public methods

default 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)), but also includes the virtual device id of the op is now active or inactive.

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

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

Public methods

onOpActiveChanged

Added in API level 35
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)), 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 only.

If implemented, ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int)) will not be called automatically.

Parameters
op String: The operation that changed. This value cannot be null.

uid int: The UID performing the operation.

packageName String: The package performing the operation. This value cannot be null.

attributionTag String: The operation's attribution tag. This value may be null.

virtualDeviceId int: the virtual device id whose operation has changed

active boolean: Whether the operation became active or inactive.

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

attributionChainId int: the unique id of the attribution chain this op is a part of.

onOpActiveChanged

Added in API level 30
public abstract void onOpActiveChanged (String op, 
                int uid, 
                String packageName, 
                boolean active)

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

Parameters
op String: The operation that changed. This value cannot be null.

uid int

packageName String: The package performing the operation. This value cannot be null.

active boolean: Whether the operation became active or inactive.