Stay organized with collections
Save and categorize content based on your preferences.
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
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
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AppOpsManager.OnOpActiveChangedListener\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nAppOpsManager.OnOpActiveChangedListener\n=======================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/app/AppOpsManager.OnOpActiveChangedListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nAppOpsManager.OnOpActiveChangedListener\n`\n\n\n`\n\n\n`\n\n|-----------------------------------------------------|\n| android.app.AppOpsManager.OnOpActiveChangedListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCallback for notification of changes to operation active state.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[onOpActiveChanged](/reference/android/app/AppOpsManager.OnOpActiveChangedListener#onOpActiveChanged(java.lang.String,%20int,%20java.lang.String,%20java.lang.String,%20int,%20boolean,%20int,%20int))`(`[String](/reference/java/lang/String)` op, int uid, `[String](/reference/java/lang/String)` packageName, `[String](/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))](/), but also includes the virtual device id of the op is now active or inactive. |\n| ` abstract void` | ` `[onOpActiveChanged](/reference/android/app/AppOpsManager.OnOpActiveChangedListener#onOpActiveChanged(java.lang.String,%20int,%20java.lang.String,%20boolean))`(`[String](/reference/java/lang/String)` op, int uid, `[String](/reference/java/lang/String)` packageName, boolean active) ` Called when the active state of an app-op changes. |\n\nPublic methods\n--------------\n\n### onOpActiveChanged\n\nAdded in [API level 35](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void onOpActiveChanged (String op, \n int uid, \n String packageName, \n String attributionTag, \n int virtualDeviceId, \n boolean active, \n int attributionFlags, \n int attributionChainId)\n```\n\nSimilar to [ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int))](/),\nbut also includes the virtual device id of the op is now active or inactive.\n\nImplement this method if callbacks are required on all devices.\nIf not implemented explicitly, the default implementation will notify for op state\nchanges on the default device [Context.DEVICE_ID_DEFAULT](/reference/android/content/Context#DEVICE_ID_DEFAULT) only.\n\nIf implemented,\n[ERROR(/#onOpActiveChanged(java.lang.String,int,java.lang.String,java.lang.String,boolean,int,int))](/)\nwill not be called automatically.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `op` | `String`: The operation that changed. This value cannot be `null`. \u003cbr /\u003e |\n| `uid` | `int`: The UID performing the operation. \u003cbr /\u003e |\n| `packageName` | `String`: The package performing the operation. This value cannot be `null`. \u003cbr /\u003e |\n| `attributionTag` | `String`: The operation's attribution tag. This value may be `null`. \u003cbr /\u003e |\n| `virtualDeviceId` | `int`: the virtual device id whose operation has changed \u003cbr /\u003e |\n| `active` | `boolean`: Whether the operation became active or inactive. \u003cbr /\u003e |\n| `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 \u003cbr /\u003e |\n| `attributionChainId` | `int`: the unique id of the attribution chain this op is a part of. \u003cbr /\u003e |\n\n### onOpActiveChanged\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onOpActiveChanged (String op, \n int uid, \n String packageName, \n boolean active)\n```\n\nCalled when the active state of an app-op changes.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|-------------------------------------------------------------------------------------|\n| `op` | `String`: The operation that changed. This value cannot be `null`. \u003cbr /\u003e |\n| `uid` | `int` \u003cbr /\u003e |\n| `packageName` | `String`: The package performing the operation. This value cannot be `null`. \u003cbr /\u003e |\n| `active` | `boolean`: Whether the operation became active or inactive. \u003cbr /\u003e |"]]