Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#inhmethods)

# DevicePolicyResourcesManager

*** ** * ** ***


`
public


class
DevicePolicyResourcesManager
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.admin.DevicePolicyResourcesManager |

<br />

*** ** * ** ***

Class containing required APIs to set, reset, and get device policy related resources.

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/android/graphics/drawable/Drawable> defaultDrawableLoader) ` Returns the appropriate updated drawable for the `drawableId` with style `drawableStyle` if one was set using `setDrawables`, otherwise returns the drawable from `defaultDrawableLoader`. |
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, https://developer.android.com/reference/java/lang/String drawableSource, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/android/graphics/drawable/Drawable> defaultDrawableLoader) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts a `drawableSource` which could result in returning a different drawable than `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` if an override was set for that specific source. |
| ` https://developer.android.com/reference/android/graphics/drawable/Icon` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawableAsIcon(java.lang.String,%20java.lang.String,%20java.lang.String,%20android.graphics.drawable.Icon)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, https://developer.android.com/reference/java/lang/String drawableSource, https://developer.android.com/reference/android/graphics/drawable/Icon defaultIcon) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` but returns an `https://developer.android.com/reference/android/graphics/drawable/Icon` instead of a `https://developer.android.com/reference/android/graphics/drawable/Drawable`. |
| ` https://developer.android.com/reference/android/graphics/drawable/Icon` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawableAsIcon(java.lang.String,%20java.lang.String,%20android.graphics.drawable.Icon)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, https://developer.android.com/reference/android/graphics/drawable/Icon defaultIcon) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` but returns an `https://developer.android.com/reference/android/graphics/drawable/Icon` instead of a `https://developer.android.com/reference/android/graphics/drawable/Drawable`. |
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawableForDensity(java.lang.String,%20java.lang.String,%20int,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, int density, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/android/graphics/drawable/Drawable> defaultDrawableLoader) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts `density`. |
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawableForDensity(java.lang.String,%20java.lang.String,%20java.lang.String,%20int,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)(https://developer.android.com/reference/java/lang/String drawableId, https://developer.android.com/reference/java/lang/String drawableStyle, https://developer.android.com/reference/java/lang/String drawableSource, int density, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/android/graphics/drawable/Drawable> defaultDrawableLoader) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts `density`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getString(java.lang.String,%20java.util.function.Supplier<java.lang.String>,%20java.lang.Object[])(https://developer.android.com/reference/java/lang/String stringId, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/java/lang/String> defaultStringLoader, https://developer.android.com/reference/java/lang/Object formatArgs) ` Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getString(java.lang.String,%20java.util.function.Supplier<java.lang.String>)` but accepts `formatArgs` and returns a localized formatted string, substituting the format arguments as defined in `https://developer.android.com/reference/java/util/Formatter` and `https://developer.android.com/reference/java/lang/String#format(java.lang.String,%20java.lang.Object[])`, (see `https://developer.android.com/reference/android/content/res/Resources#getString(int,%20java.lang.Object[])`). |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getString(java.lang.String,%20java.util.function.Supplier<java.lang.String>)(https://developer.android.com/reference/java/lang/String stringId, https://developer.android.com/reference/java/util/function/Supplier<https://developer.android.com/reference/java/lang/String> defaultStringLoader) ` Returns the appropriate updated string for the `stringId` (see `DevicePolicyResources.Strings`) if one was set using `setStrings`, otherwise returns the string from `defaultStringLoader`. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public methods

### getDrawable

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

```
public Drawable getDrawable (String drawableId, 
                String drawableStyle, 
                Supplier<Drawable> defaultDrawableLoader)
```

Returns the appropriate updated drawable for the `drawableId` with style `drawableStyle` if one was set using `setDrawables`, otherwise returns the drawable from
`defaultDrawableLoader`.

Also returns the drawable from `defaultDrawableLoader` if `drawableId` is
`https://developer.android.com/reference/android/app/admin/DevicePolicyResources#UNDEFINED`.

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultDrawableLoader` returned `null`.

This API uses the screen density returned from `https://developer.android.com/reference/android/content/res/Resources#getConfiguration()`, to
set a different value use `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawableForDensity(java.lang.String,%20java.lang.String,%20int,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`.

Callers should register for `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED` to get notified when a resource
has been updated.

Note that each call to this API loads the resource from the package that called `setDrawables` to set the updated resource.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `defaultDrawableLoader` | `Supplier`: To get the default drawable if no updated drawable was set for the provided params. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | <br /> |

### getDrawable

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

```
public Drawable getDrawable (String drawableId, 
                String drawableStyle, 
                String drawableSource, 
                Supplier<Drawable> defaultDrawableLoader)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts a `drawableSource` which could result in returning a different drawable than `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` if an override was set for that specific source.

If `drawableSource` is `https://developer.android.com/reference/android/app/admin/DevicePolicyResources#UNDEFINED`, it returns the
appropriate string for `drawableId` and `drawableStyle` similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`.

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultDrawableLoader` returned `null`.

Callers should register for `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED` to get notified when a resource
has been updated.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `drawableSource` | `String`: The source for the caller. This value cannot be `null`. <br /> |
| `defaultDrawableLoader` | `Supplier`: To get the default drawable if no updated drawable was set for the provided params. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | <br /> |

### getDrawableAsIcon

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

```
public Icon getDrawableAsIcon (String drawableId, 
                String drawableStyle, 
                String drawableSource, 
                Icon defaultIcon)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` but returns an `https://developer.android.com/reference/android/graphics/drawable/Icon`
instead of a `https://developer.android.com/reference/android/graphics/drawable/Drawable`.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `drawableSource` | `String`: The source for the caller. This value cannot be `null`. <br /> |
| `defaultIcon` | `Icon`: Returned if no updated drawable was set for the provided params. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon` | This value may be `null`. <br /> |

### getDrawableAsIcon

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

```
public Icon getDrawableAsIcon (String drawableId, 
                String drawableStyle, 
                Icon defaultIcon)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)` but returns an `https://developer.android.com/reference/android/graphics/drawable/Icon` instead
of a `https://developer.android.com/reference/android/graphics/drawable/Drawable`.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `defaultIcon` | `Icon`: Returned if no updated drawable was set for the provided params. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Icon` | This value may be `null`. <br /> |

### getDrawableForDensity

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

```
public Drawable getDrawableForDensity (String drawableId, 
                String drawableStyle, 
                int density, 
                Supplier<Drawable> defaultDrawableLoader)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts `density`.
See `https://developer.android.com/reference/android/content/res/Resources#getDrawableForDensity(int,%20int,%20android.content.res.Resources.Theme)`.

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultDrawableLoader` returned `null`.

Callers should register for `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED` to get notified when a resource
has been updated.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `density` | `int`: The desired screen density indicated by the resource as found in `https://developer.android.com/reference/android/util/DisplayMetrics`. A value of 0 means to use the density returned from `https://developer.android.com/reference/android/content/res/Resources#getConfiguration()`. <br /> |
| `defaultDrawableLoader` | `Supplier`: To get the default drawable if no updated drawable was set for the provided params. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | <br /> |

### getDrawableForDensity

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

```
public Drawable getDrawableForDensity (String drawableId, 
                String drawableStyle, 
                String drawableSource, 
                int density, 
                Supplier<Drawable> defaultDrawableLoader)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getDrawable(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.function.Supplier<android.graphics.drawable.Drawable>)`, but also accepts `density`. See `https://developer.android.com/reference/android/content/res/Resources#getDrawableForDensity(int,%20int,%20android.content.res.Resources.Theme)`.

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultDrawableLoader` returned `null`.

Callers should register for `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED` to get notified when a resource
has been updated.

<br />

| Parameters ||
|---|---|
| `drawableId` | `String`: The drawable ID to get the updated resource for. This value cannot be `null`. <br /> |
| `drawableStyle` | `String`: The drawable style to use. This value cannot be `null`. <br /> |
| `drawableSource` | `String`: The source for the caller. This value cannot be `null`. <br /> |
| `density` | `int`: The desired screen density indicated by the resource as found in `https://developer.android.com/reference/android/util/DisplayMetrics`. A value of 0 means to use the density returned from `https://developer.android.com/reference/android/content/res/Resources#getConfiguration()`. <br /> |
| `defaultDrawableLoader` | `Supplier`: To get the default drawable if no updated drawable was set for the provided params. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | <br /> |

### getString

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

```
public String getString (String stringId, 
                Supplier<String> defaultStringLoader, 
                Object... formatArgs)
```

Similar to `https://developer.android.com/reference/android/app/admin/DevicePolicyResourcesManager#getString(java.lang.String,%20java.util.function.Supplier<java.lang.String>)` but accepts `formatArgs` and returns a
localized formatted string, substituting the format arguments as defined in `https://developer.android.com/reference/java/util/Formatter` and `https://developer.android.com/reference/java/lang/String#format(java.lang.String,%20java.lang.Object[])`, (see `https://developer.android.com/reference/android/content/res/Resources#getString(int,%20java.lang.Object[])`).

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultStringLoader` returned `null`.

<br />

| Parameters ||
|---|---|
| `stringId` | `String`: The IDs to get the updated resource for. This value cannot be `null`. <br /> |
| `defaultStringLoader` | `Supplier`: To get the default string if no updated string was set for `stringId`. This value cannot be `null`. <br /> |
| `formatArgs` | `Object`: The format arguments that will be used for substitution. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getString

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

```
public String getString (String stringId, 
                Supplier<String> defaultStringLoader)
```

Returns the appropriate updated string for the `stringId` (see `DevicePolicyResources.Strings`) if one was set using `setStrings`, otherwise returns
the string from `defaultStringLoader`.

Also returns the string from `defaultStringLoader` if `stringId` is `https://developer.android.com/reference/android/app/admin/DevicePolicyResources#UNDEFINED`.

Calls to this API will not return `null` unless no updated drawable was found and
the call to `defaultStringLoader` returned `null`.

Callers should register for `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED` to get notified when a resource
has been updated.

Note that each call to this API loads the resource from the package that called `setStrings` to set the updated resource.

<br />

| Parameters ||
|---|---|
| `stringId` | `String`: The IDs to get the updated resource for. This value cannot be `null`. <br /> |
| `defaultStringLoader` | `Supplier`: To get the default string if no updated string was set for `stringId`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |