# AppOpsManagerCompat

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Constants](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#constants)\|[Methods](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#)  

# AppOpsManagerCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
AppOpsManagerCompat
`  
`

extends Object


``


`

|---|--------------------------------------------|
| java.lang.Object                              ||
| ↳ | android.support.v4.app.AppOpsManagerCompat |

<br />

*** ** * ** ***

Helper for accessing features in[AppOpsManager](https://developer.android.com/reference/android/app/AppOpsManager.html).

## Summary

|                                                                                                                                                                                                                                                                                   ### Constants                                                                                                                                                                                                                                                                                   ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [MODE_ALLOWED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ALLOWED) Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is allowed to perform the given operation.                                                                                                                                                                                |
| `int` | [MODE_DEFAULT](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_DEFAULT) Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller should use its default security check.                                                                                                                                                                                    |
| `int` | [MODE_ERRORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ERRORED) Result from[noteOpNoThrow(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOpNoThrow(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is not allowed to perform the given operation, and this attempt should cause it to have a fatal error, typically a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException). |
| `int` | [MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED) Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is not allowed to perform the given operation, and this attempt should*silently fail*(it should not cause the app to crash).                                                                                              |

|                                                                                                                                                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                                                                                                                                                          ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static int`    | ` `[noteOp](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String op, int uid, String packageName) ` Make note of an application performing an operation.                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` static int`    | ` `[noteOpNoThrow](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOpNoThrow(android.content.Context, java.lang.String, int, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String op, int uid, String packageName) ` Like[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String))but instead of throwing a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException)it returns[MODE_ERRORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ERRORED).    |
| ` static int`    | ` `[noteProxyOp](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteProxyOp(android.content.Context, java.lang.String, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String op, String proxiedPackageName) ` Make note of an application performing an operation on behalf of another application when handling an IPC.                                                                                                                                                                                                                                                                                                                                                       |
| ` static int`    | ` `[noteProxyOpNoThrow](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteProxyOpNoThrow(android.content.Context, java.lang.String, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String op, String proxiedPackageName) ` Like[noteProxyOp(Context, String, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteProxyOp(android.content.Context, java.lang.String, java.lang.String))but instead of throwing a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException)it returns[MODE_ERRORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ERRORED). |
| ` static String` | ` `[permissionToOp](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#permissionToOp(java.lang.String))`(String permission) ` Gets the app op name associated with a given permission.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### MODE_ALLOWED

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

```
int MODE_ALLOWED
```

Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is allowed to perform the given operation.

<br />

Constant Value: 0 (0x00000000)  

### MODE_DEFAULT

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

```
int MODE_DEFAULT
```

Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller should use its default security check. This mode is not normally used; it should only be used with appop permissions, and callers must explicitly check for it and deal with it.

<br />

Constant Value: 3 (0x00000003)  

### MODE_ERRORED

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

```
int MODE_ERRORED
```

Result from[noteOpNoThrow(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOpNoThrow(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is not allowed to perform the given operation, and this attempt should cause it to have a fatal error, typically a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException).

<br />

Constant Value: 2 (0x00000002)  

### MODE_IGNORED

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

```
int MODE_IGNORED
```

Result from[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String)): the given caller is not allowed to perform the given operation, and this attempt should*silently fail*(it should not cause the app to crash).

<br />

Constant Value: 1 (0x00000001)

## Public methods

### noteOp

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

```
int noteOp (Context context, 
                String op, 
                int uid, 
                String packageName)
```

Make note of an application performing an operation. Note that you must pass in both the uid and name of the application to be checked; this function will verify that these two match, and if not, return[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED). If this call succeeds, the last execution time of the operation for this app will be updated to the current time.

**Compatibility**

- On API 18 and lower, this method always returns[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)

<br />

<br />

|                                            Parameters                                            ||
|---------------|-----------------------------------------------------------------------------------|
| `context`     | `Context`: Your context. <br />                                                   |
| `op`          | `String`: The operation to note. One of the OPSTR_\* constants. <br />            |
| `uid`         | `int`: The user id of the application attempting to perform the operation. <br /> |
| `packageName` | `String`: The name of the application attempting to perform the operation. <br /> |

|                                                                                                                                                                                  Returns                                                                                                                                                                                  ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | Returns[MODE_ALLOWED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ALLOWED)if the operation is allowed, or[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)if it is not allowed and should be silently ignored (without causing the app to crash). <br /> |

|                                  Throws                                  ||
|---------------------|-----------------------------------------------------|
| `SecurityException` | If the app has been configured to crash on this op. |

### noteOpNoThrow

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

```
int noteOpNoThrow (Context context, 
                String op, 
                int uid, 
                String packageName)
```

Like[noteOp(Context, String, int, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteOp(android.content.Context, java.lang.String, int, java.lang.String))but instead of throwing a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException)it returns[MODE_ERRORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ERRORED).

**Compatibility**

- On API 18 and lower, this method always returns[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)

<br />

<br />

|           Parameters            ||
|---------------|------------------|
| `context`     | `Context` <br /> |
| `op`          | `String` <br />  |
| `uid`         | `int` <br />     |
| `packageName` | `String` <br />  |

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

### noteProxyOp

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

```
int noteProxyOp (Context context, 
                String op, 
                String proxiedPackageName)
```

Make note of an application performing an operation on behalf of another application when handling an IPC. Note that you must pass the package name of the application that is being proxied while its UID will be inferred from the IPC state; this function will verify that the calling uid and proxied package name match, and if not, return[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED). If this call succeeds, the last execution time of the operation for the proxied app and your app will be updated to the current time.

**Compatibility**

- On API 22 and lower, this method always returns[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)

<br />

<br />

|                                               Parameters                                               ||
|----------------------|----------------------------------------------------------------------------------|
| `context`            | `Context`: Your context. <br />                                                  |
| `op`                 | `String`: The operation to note. One of the OPSTR_\* constants. <br />           |
| `proxiedPackageName` | `String`: The name of the application calling into the proxy application. <br /> |

|                                                                                                                                                                                  Returns                                                                                                                                                                                  ||
|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | Returns[MODE_ALLOWED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ALLOWED)if the operation is allowed, or[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)if it is not allowed and should be silently ignored (without causing the app to crash). <br /> |

|                                  Throws                                  ||
|---------------------|-----------------------------------------------------|
| `SecurityException` | If the app has been configured to crash on this op. |

### noteProxyOpNoThrow

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

```
int noteProxyOpNoThrow (Context context, 
                String op, 
                String proxiedPackageName)
```

Like[noteProxyOp(Context, String, String)](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#noteProxyOp(android.content.Context, java.lang.String, java.lang.String))but instead of throwing a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException)it returns[MODE_ERRORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_ERRORED).

**Compatibility**

- On API 22 and lower, this method always returns[MODE_IGNORED](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat#MODE_IGNORED)

<br />

<br />

|               Parameters               ||
|----------------------|------------------|
| `context`            | `Context` <br /> |
| `op`                 | `String` <br />  |
| `proxiedPackageName` | `String` <br />  |

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

### permissionToOp

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

```
String permissionToOp (String permission)
```

Gets the app op name associated with a given permission.

**Compatibility**

- On API 22 and lower, this method always returns`null`

<br />

<br />

|                   Parameters                   ||
|--------------|----------------------------------|
| `permission` | `String`: The permission. <br /> |

|                               Returns                               ||
|----------|-----------------------------------------------------------|
| `String` | The app op associated with the permission or null. <br /> |

-

  ## Annotations

  - [NotificationCompat.Action.SemanticAction](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.SemanticAction)
-

  ## Interfaces

  - [ActionBarDrawerToggle.Delegate](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.Delegate)
  - [ActionBarDrawerToggle.DelegateProvider](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.DelegateProvider)
  - [ActivityCompat.OnRequestPermissionsResultCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback)
  - [ActivityCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.PermissionCompatDelegate)
  - [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/support/v4/app/FragmentManager.BackStackEntry)
  - [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)
  - [LoaderManager.LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)
  - [NotificationCompat.Action.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Extender)
  - [NotificationCompat.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Extender)
  - [SharedElementCallback.OnSharedElementsReadyListener](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback.OnSharedElementsReadyListener)
  - [TaskStackBuilder.SupportParentable](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.SupportParentable)
-

  ## Classes

  - [ActionBarDrawerToggle](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle)
  - [ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)
  - [ActivityManagerCompat](https://developer.android.com/reference/android/support/v4/app/ActivityManagerCompat)
  - [ActivityOptionsCompat](https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat)
  - [AlarmManagerCompat](https://developer.android.com/reference/android/support/v4/app/AlarmManagerCompat)
  - [AppLaunchChecker](https://developer.android.com/reference/android/support/v4/app/AppLaunchChecker)
  - [AppOpsManagerCompat](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat)
  - [BundleCompat](https://developer.android.com/reference/android/support/v4/app/BundleCompat)
  - [DialogFragment](https://developer.android.com/reference/android/support/v4/app/DialogFragment)
  - [Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)
  - [Fragment.SavedState](https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState)
  - [FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)
  - [FragmentContainer](https://developer.android.com/reference/android/support/v4/app/FragmentContainer)
  - [FragmentController](https://developer.android.com/reference/android/support/v4/app/FragmentController)
  - [FragmentHostCallback](https://developer.android.com/reference/android/support/v4/app/FragmentHostCallback)
  - [FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)
  - [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)
  - [FragmentManagerNonConfig](https://developer.android.com/reference/android/support/v4/app/FragmentManagerNonConfig)
  - [FragmentPagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter)
  - [FragmentStatePagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter)
  - [FragmentTabHost](https://developer.android.com/reference/android/support/v4/app/FragmentTabHost)
  - [FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)
  - [FrameMetricsAggregator](https://developer.android.com/reference/android/support/v4/app/FrameMetricsAggregator)
  - [JobIntentService](https://developer.android.com/reference/android/support/v4/app/JobIntentService)
  - [ListFragment](https://developer.android.com/reference/android/support/v4/app/ListFragment)
  - [LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager)
  - [NavUtils](https://developer.android.com/reference/android/support/v4/app/NavUtils)
  - [NotificationCompat](https://developer.android.com/reference/android/support/v4/app/NotificationCompat)
  - [NotificationCompat.Action](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action)
  - [NotificationCompat.Action.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Builder)
  - [NotificationCompat.Action.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.WearableExtender)
  - [NotificationCompat.BigPictureStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigPictureStyle)
  - [NotificationCompat.BigTextStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigTextStyle)
  - [NotificationCompat.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder)
  - [NotificationCompat.CarExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender)
  - [NotificationCompat.CarExtender.UnreadConversation](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation)
  - [NotificationCompat.CarExtender.UnreadConversation.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation.Builder)
  - [NotificationCompat.DecoratedCustomViewStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.DecoratedCustomViewStyle)
  - [NotificationCompat.InboxStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.InboxStyle)
  - [NotificationCompat.MessagingStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle)
  - [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle.Message)
  - [NotificationCompat.Style](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Style)
  - [NotificationCompat.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender)
  - [NotificationCompatExtras](https://developer.android.com/reference/android/support/v4/app/NotificationCompatExtras)
  - [NotificationCompatSideChannelService](https://developer.android.com/reference/android/support/v4/app/NotificationCompatSideChannelService)
  - [NotificationManagerCompat](https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat)
  - [RemoteInput](https://developer.android.com/reference/android/support/v4/app/RemoteInput)
  - [RemoteInput.Builder](https://developer.android.com/reference/android/support/v4/app/RemoteInput.Builder)
  - [ServiceCompat](https://developer.android.com/reference/android/support/v4/app/ServiceCompat)
  - [ShareCompat](https://developer.android.com/reference/android/support/v4/app/ShareCompat)
  - [ShareCompat.IntentBuilder](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentBuilder)
  - [ShareCompat.IntentReader](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentReader)
  - [SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)
  - [TaskStackBuilder](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder)
-

  ## Exceptions

  - [Fragment.InstantiationException](https://developer.android.com/reference/android/support/v4/app/Fragment.InstantiationException)