Freigeben über


DevicePolicyManager.SetAutoTimeRequired(ComponentName, Boolean) Method

Definition

Called by a device owner, or alternatively a profile owner from Android 8.

[Android.Runtime.Register("setAutoTimeRequired", "(Landroid/content/ComponentName;Z)V", "GetSetAutoTimeRequired_Landroid_content_ComponentName_ZHandler")]
public virtual void SetAutoTimeRequired (Android.Content.ComponentName admin, bool required);
[<Android.Runtime.Register("setAutoTimeRequired", "(Landroid/content/ComponentName;Z)V", "GetSetAutoTimeRequired_Landroid_content_ComponentName_ZHandler")>]
abstract member SetAutoTimeRequired : Android.Content.ComponentName * bool -> unit
override this.SetAutoTimeRequired : Android.Content.ComponentName * bool -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

required
Boolean

Whether auto time is set required or not.

Attributes

Remarks

Called by a device owner, or alternatively a profile owner from Android 8.0 (API level 26) or higher, to set whether auto time is required. If auto time is required, no user will be able set the date and time and network date and time will be used.

Note: If auto time is required the user can still manually set the time zone. Staring from Android 11, if auto time is required, the user cannot manually set the time zone.

The calling device admin must be a device owner, or alternatively a profile owner from Android 8.0 (API level 26) or higher. If it is not, a security exception will be thrown.

Staring from Android 11, this API switches to use UserManager#DISALLOW_CONFIG_DATE_TIME to enforce the auto time settings. Calling this API to enforce auto time will result in UserManager#DISALLOW_CONFIG_DATE_TIME being set, while calling this API to lift the requirement will result in UserManager#DISALLOW_CONFIG_DATE_TIME being cleared. From Android 11, this API can also no longer be called on a managed profile.

This member is deprecated. From android.os.Build.VERSION_CODES#R. Use #setAutoTimeEnabled to turn auto time on or off and use UserManager#DISALLOW_CONFIG_DATE_TIME to prevent the user from changing this setting.

Java documentation for android.app.admin.DevicePolicyManager.setAutoTimeRequired(android.content.ComponentName, boolean).

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