Added in API level 30

OnOpActiveChangedListener


interface OnOpActiveChangedListener
android.app.AppOpsManager.OnOpActiveChangedListener

Callback for notification of changes to operation active state.

Summary

Public methods
abstract Unit
onOpActiveChanged(op: String, uid: Int, packageName: String, active: Boolean)

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

open Unit
onOpActiveChanged(op: String, uid: Int, packageName: String, attributionTag: String?, virtualDeviceId: Int, active: Boolean, attributionFlags: Int, attributionChainId: Int)

Similar to #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.

Public methods

onOpActiveChanged

Added in API level 30
abstract fun onOpActiveChanged(
    op: String,
    uid: Int,
    packageName: String,
    active: Boolean
): Unit

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

Parameters
op String: The operation that changed. This value cannot be null.
packageName String: The package performing the operation. This value cannot be null.
active Boolean: Whether the operation became active or inactive.

onOpActiveChanged

Added in API level 35
open fun onOpActiveChanged(
    op: String,
    uid: Int,
    packageName: String,
    attributionTag: String?,
    virtualDeviceId: Int,
    active: Boolean,
    attributionFlags: Int,
    attributionChainId: Int
): Unit

Similar to #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, #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.