Share via


DevicePolicyManager.SetSecureSetting(ComponentName, String, String) Method

Definition

This method is mostly deprecated.

[Android.Runtime.Register("setSecureSetting", "(Landroid/content/ComponentName;Ljava/lang/String;Ljava/lang/String;)V", "GetSetSecureSetting_Landroid_content_ComponentName_Ljava_lang_String_Ljava_lang_String_Handler")]
public virtual void SetSecureSetting (Android.Content.ComponentName admin, string? setting, string? value);
[<Android.Runtime.Register("setSecureSetting", "(Landroid/content/ComponentName;Ljava/lang/String;Ljava/lang/String;)V", "GetSetSecureSetting_Landroid_content_ComponentName_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member SetSecureSetting : Android.Content.ComponentName * string * string -> unit
override this.SetSecureSetting : Android.Content.ComponentName * string * string -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

setting
String

The name of the setting to update.

value
String

The value to update the setting to.

Attributes

Remarks

This method is mostly deprecated. Most of the settings that still have an effect have dedicated setter methods (e.g. #setLocationEnabled) or user restrictions.

Called by profile or device owners to update android.provider.Settings.Secure settings. Validation that the value of the setting is in the correct form for the setting type should be performed by the caller.

The settings that can be updated by a profile or device owner with this method are: <ul> <li>android.provider.Settings.Secure#DEFAULT_INPUT_METHOD</li> <li>android.provider.Settings.Secure#SKIP_FIRST_USE_HINTS</li> </ul>

A device owner can additionally update the following settings: <ul> <li>android.provider.Settings.Secure#LOCATION_MODE, but see note below.</li> </ul>

<strong>Note: Starting from Android O, apps should no longer call this method with the setting android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS, which is deprecated. Instead, device owners or profile owners should use the restriction UserManager#DISALLOW_INSTALL_UNKNOWN_SOURCES. If any app targeting android.os.Build.VERSION_CODES#O or higher calls this method with android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS, an UnsupportedOperationException is thrown.

Starting from Android Q, the device and profile owner can also call UserManager#DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY to restrict unknown sources for all users. </strong>

<strong>Note: Starting from Android R, apps should no longer call this method with the setting android.provider.Settings.Secure#LOCATION_MODE, which is deprecated. Instead, device owners should call #setLocationEnabled(ComponentName, boolean). This will be enforced for all apps targeting Android R or above. </strong>

Java documentation for android.app.admin.DevicePolicyManager.setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to