Share via


UiModeManager.SetApplicationNightMode(Int32) Method

Definition

Sets and persist the night mode for this application.

[Android.Runtime.Register("setApplicationNightMode", "(I)V", "GetSetApplicationNightMode_IHandler", ApiSince=31)]
public virtual void SetApplicationNightMode (int mode);
[<Android.Runtime.Register("setApplicationNightMode", "(I)V", "GetSetApplicationNightMode_IHandler", ApiSince=31)>]
abstract member SetApplicationNightMode : int -> unit
override this.SetApplicationNightMode : int -> unit

Parameters

mode
Int32

the night mode to set

Attributes

Remarks

Sets and persist the night mode for this application.

The mode can be one of: <ul> <li><em>#MODE_NIGHT_NO<em> sets the device into notnight mode</li> <li><em>#MODE_NIGHT_YES</em> sets the device into night mode</li> <li><em>#MODE_NIGHT_CUSTOM</em> automatically switches between night and notnight based on the custom time set (or default)</li> <li><em>#MODE_NIGHT_AUTO</em> automatically switches between night and notnight based on the device's current location and certain other sensors</li> </ul>

Changes to night mode take effect locally and will result in a configuration change (and potentially an Activity lifecycle event) being applied to this application. The mode is persisted for this application until it is either modified by the application, the user clears the data for the application, or this application is uninstalled.

Developers interested in a non-persistent app-local implementation of night mode should consider using androidx.appcompat.app.AppCompatDelegate#setDefaultNightMode(int) to manage the -night qualifier locally.

Java documentation for android.app.UiModeManager.setApplicationNightMode(int).

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