# AppCompatDelegate

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/app/AppCompatDelegate.java+class:androidx.appcompat.app.AppCompatDelegate) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***

<br />

```
public abstract class AppCompatDelegate
```

<br />

*** ** * ** ***

This class represents a delegate which you can use to extend AppCompat's support to any `https://developer.android.com/reference/android/app/Activity.html`.

When using an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate`, you should call the following methods instead of the `https://developer.android.com/reference/android/app/Activity.html` method of the same name:

- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#addContentView(android.view.View,android.view.ViewGroup.LayoutParams)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(int)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(android.view.View)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(android.view.View,android.view.ViewGroup.LayoutParams)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#requestWindowFeature(int)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#hasWindowFeature(int)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#invalidateOptionsMenu()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#startSupportActionMode(androidx.appcompat.view.ActionMode.Callback)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setSupportActionBar(androidx.appcompat.widget.Toolbar)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getSupportActionBar()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getMenuInflater()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#findViewById(int)`

The following methods should be called from the `https://developer.android.com/reference/android/app/Activity.html` method of the same name:

- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onCreate(android.os.Bundle)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onPostCreate(android.os.Bundle)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onConfigurationChanged(android.content.res.Configuration)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onStart()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onStop()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onPostResume()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onSaveInstanceState(android.os.Bundle)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setTitle(java.lang.CharSequence)`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onStop()`
- `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onDestroy()`

An `https://developer.android.com/reference/android/app/Activity.html` can only be linked with one `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` instance, therefore the instance returned from `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#create(android.app.Activity,androidx.appcompat.app.AppCompatCallback)` should be retained until the Activity is destroyed.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#FEATURE_ACTION_MODE_OVERLAY() = 10` Flag for specifying the behavior of action modes when an Action Bar is not present. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR() = 108` Flag for enabling the support Action Bar. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR_OVERLAY() = 109` Flag for requesting an support Action Bar that overlays window content. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO() = 0` **This field is deprecated.** Use `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO_TIME()` instead <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO_BATTERY() = 3` Night mode which uses a dark mode when the system's 'Battery Saver' feature is enabled, otherwise it uses a 'light mode'. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO_TIME() = 0` **This field is deprecated.** Automatic switching of dark/light based on the current time is deprecated. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_FOLLOW_SYSTEM() = -1` Mode which uses the system's night mode setting to determine if it is night or not. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_NO() = 1` Night mode which uses always uses a light mode, enabling `notnight` qualified resources regardless of the time. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_UNSPECIFIED() = -100` An unspecified mode for night mode. |
| `static final int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_YES() = 2` Night mode which uses always uses a dark mode, enabling `night` qualified resources regardless of the time. |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#addContentView(android.view.View,android.view.ViewGroup.LayoutParams)(https://developer.android.com/reference/android/view/View.html v, https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html lp)` Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#addContentView(android.view.View, android.view.ViewGroup.LayoutParams)`} |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#applyDayNight()()` Applies the currently selected night mode to this delegate's host component. |
| `void` | `[attachBaseContext](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#attachBaseContext(android.content.Context))(https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** use `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#attachBaseContext2(android.content.Context)` instead. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#attachBaseContext2(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` Should be called from `https://developer.android.com/reference/android/app/Activity.html#attachBaseContext(android.content.Context)`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#create(android.app.Activity,androidx.appcompat.app.AppCompatCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback)` Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with `activity`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#create(android.app.Dialog,androidx.appcompat.app.AppCompatCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Dialog.html dialog, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback)` Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with `dialog`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#create(android.content.Context,android.app.Activity,androidx.appcompat.app.AppCompatCallback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback )` Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with a `context` and hosted by an `Activity`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#create(android.content.Context,android.view.Window,androidx.appcompat.app.AppCompatCallback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Window.html window, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback )` Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with a `context` and a `window`. |
| `abstract https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#createView(android.view.View,java.lang.String,android.content.Context,android.util.AttributeSet)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html parent, https://developer.android.com/reference/java/lang/String.html name, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/AttributeSet.html attrs )` This should be called from a `https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html` in order to return tint-aware widgets. |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html T` | `<T extends https://developer.android.com/reference/android/view/View.html> https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#findViewById(int)(@https://developer.android.com/reference/androidx/annotation/IdRes int id)` Finds a view that was identified by the id attribute from the XML that was processed in `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onCreate(android.os.Bundle)`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/os/LocaleListCompat` | `@https://developer.android.com/reference/androidx/annotation/AnyThread https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getApplicationLocales()()` Returns application locales for the calling app as a `https://developer.android.com/reference/androidx/core/os/LocaleListCompat`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getContextForDelegate()()` Returns the context for the current delegate. |
| `static int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getDefaultNightMode()()` Returns the default night mode. |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle.Delegate` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getDrawerToggleDelegate()()` Returns an `https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle.Delegate` which can be returned from your Activity if it implements `https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle.DelegateProvider`. |
| `int` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getLocalNightMode()()` Returns the night mode previously set via `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getLocalNightMode()`. |
| `abstract https://developer.android.com/reference/android/view/MenuInflater.html` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getMenuInflater()()` Return the value of this call from your `https://developer.android.com/reference/android/app/Activity.html#getMenuInflater()` |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/ActionBar` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getSupportActionBar()()` Support library version of `https://developer.android.com/reference/android/app/Activity.html#getActionBar()`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#hasWindowFeature(int)(int featureId)` Query for the availability of a certain feature. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#installViewFactory()()` Installs AppCompat's `https://developer.android.com/reference/android/view/LayoutInflater.html` Factory so that it can replace the framework widgets with compatible tinted versions. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#invalidateOptionsMenu()()` Should be called from `https://developer.android.com/reference/android/app/Activity.html#invalidateOptionsMenu()`} or `https://developer.android.com/reference/androidx/fragment/app/FragmentActivity#supportInvalidateOptionsMenu()`. |
| `static boolean` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#isCompatVectorFromResourcesEnabled()()` Returns whether vector drawables on older platforms (\< API 21) can be accessed from within resources. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#isHandleNativeActionModesEnabled()()` Returns whether AppCompat handles any native action modes itself. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onConfigurationChanged(android.content.res.Configuration)(https://developer.android.com/reference/android/content/res/Configuration.html newConfig)` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration)` |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)`. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onDestroy()()` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onDestroy()` |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onPostCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onPostCreate(android.os.Bundle)` |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onPostResume()()` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onPostResume()` |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onSaveInstanceState(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html outState)` Allows AppCompat to save instance state. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onStart()()` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onStart()` Activity.onStart()} |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onStop()()` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onStop()` |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#requestWindowFeature(int)(int featureId)` Enable extended window features. |
| `static void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setApplicationLocales(androidx.core.os.LocaleListCompat)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/os/LocaleListCompat locales)` Sets the current locales for the calling app. |
| `static void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setCompatVectorFromResourcesEnabled(boolean)(boolean enabled)` Sets whether vector drawables on older platforms (\< API 21) can be used within `https://developer.android.com/reference/android/graphics/drawable/DrawableContainer.html` resources. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(int)(@https://developer.android.com/reference/androidx/annotation/LayoutRes int resId)` Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(int)`} |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(android.view.View)(https://developer.android.com/reference/android/view/View.html v)` Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View)`} |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setContentView(android.view.View,android.view.ViewGroup.LayoutParams)(https://developer.android.com/reference/android/view/View.html v, https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html lp)` Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)`} |
| `static void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)(int mode)` Sets the default night mode. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setHandleNativeActionModesEnabled(boolean)(boolean enabled)` Whether AppCompat handles any native action modes itself. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)(int mode)` Override the night mode used for this delegate's host component. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper @https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 33) https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setOnBackInvokedDispatcher(android.window.OnBackInvokedDispatcher)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html dispatcher)` Sets the `https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html` for handling system back for Android SDK 33 and above. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setSupportActionBar(androidx.appcompat.widget.Toolbar)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar)` Set a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` to act as the `https://developer.android.com/reference/androidx/appcompat/app/ActionBar` for this delegate. |
| `void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setTheme(int)(@https://developer.android.com/reference/androidx/annotation/StyleRes int themeResId)` This should be called from `https://developer.android.com/reference/android/app/Activity.html#setTheme(int)` to notify AppCompat of what the current theme resource id is. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setTitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title)` Should be called from `https://developer.android.com/reference/android/app/Activity.html#onTitleChanged(java.lang.CharSequence, int)`} |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/view/ActionMode` | `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#startSupportActionMode(androidx.appcompat.view.ActionMode.Callback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback callback)` Start an action mode. |

## Constants

### FEATURE_ACTION_MODE_OVERLAY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int FEATURE_ACTION_MODE_OVERLAY = 10
```

Flag for specifying the behavior of action modes when an Action Bar is not present. If overlay is enabled, the action mode UI will be allowed to cover existing window content.

### FEATURE_SUPPORT_ACTION_BAR

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int FEATURE_SUPPORT_ACTION_BAR = 108
```

Flag for enabling the support Action Bar.

This is enabled by default for some devices. The Action Bar replaces the title bar and provides an alternate location for an on-screen menu button on some devices.

### FEATURE_SUPPORT_ACTION_BAR_OVERLAY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int FEATURE_SUPPORT_ACTION_BAR_OVERLAY = 109
```

Flag for requesting an support Action Bar that overlays window content. Normally an Action Bar will sit in the space above window content, but if this feature is requested along with `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR()` it will be layered over the window content itself. This is useful if you would like your app to have more control over how the Action Bar is displayed, such as letting application content scroll beneath an Action Bar with a transparent background or otherwise displaying a transparent/translucent Action Bar over application content.

This mode is especially useful with `View.SYSTEM_UI_FLAG_FULLSCREEN`, which allows you to seamlessly hide the action bar in conjunction with other screen decorations. When an ActionBar is in this mode it will adjust the insets provided to `https://developer.android.com/reference/android/view/View.html#fitSystemWindows(android.graphics.Rect)` to include the content covered by the action bar, so you can do layout within that space.

### MODE_NIGHT_AUTO

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_AUTO = 0
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO_TIME()` instead

### MODE_NIGHT_AUTO_BATTERY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_AUTO_BATTERY = 3
```

Night mode which uses a dark mode when the system's 'Battery Saver' feature is enabled, otherwise it uses a 'light mode'. This mode can help the device to decrease power usage, depending on the display technology in the device. *Please note: this mode should only be used when running on devices which do not provide a similar device-wide setting.*

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |

### MODE_NIGHT_AUTO_TIME

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_AUTO_TIME = 0
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Automatic switching of dark/light based on the current time is deprecated. Considering using an explicit setting, or `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_AUTO_BATTERY()`.

Night mode which switches between dark and light mode depending on the time of day (dark at night, light in the day).

The calculation used to determine whether it is night or not makes use of the location APIs (if this app has the necessary permissions). This allows us to generate accurate sunrise and sunset times. If this app does not have permission to access the location APIs then we use hardcoded times which will be less accurate.

### MODE_NIGHT_FOLLOW_SYSTEM

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_FOLLOW_SYSTEM = -1
```

Mode which uses the system's night mode setting to determine if it is night or not.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |

### MODE_NIGHT_NO

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_NO = 1
```

Night mode which uses always uses a light mode, enabling `notnight` qualified resources regardless of the time.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |

### MODE_NIGHT_UNSPECIFIED

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_UNSPECIFIED = -100
```

An unspecified mode for night mode. This is primarily used with `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)`, to allow the default night mode to be used. If both the default and local night modes are set to this value, then the default value of `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_FOLLOW_SYSTEM()` is applied.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` |   |

### MODE_NIGHT_YES

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static final int MODE_NIGHT_YES = 2
```

Night mode which uses always uses a dark mode, enabling `night` qualified resources regardless of the time.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |

## Public methods

### addContentView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void addContentView(View v, ViewGroup.LayoutParams lp)
```

Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#addContentView(android.view.View, android.view.ViewGroup.LayoutParams)`}

### applyDayNight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract boolean applyDayNight()
```

Applies the currently selected night mode to this delegate's host component.

This enables the `https://developer.android.com/reference/androidx/appcompat/R.style#Theme_AppCompat_DayNight()` family of themes to work, using the specified mode.

You can be notified when the night changes by overriding the `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#onNightModeChanged(int)` method.

| Returns |
|---|---|
| `boolean` | true if the night mode was applied, false if not |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` |   |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |

### attachBaseContext

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.2.0)

```
public void [attachBaseContext](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#attachBaseContext(android.content.Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#attachBaseContext2(android.content.Context)` instead.

### attachBaseContext2

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.2.0)

```
@CallSuper
public @NonNull Context attachBaseContext2(@NonNull Context context)
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#attachBaseContext(android.content.Context)`.

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static @NonNull AppCompatDelegate create(@NonNull Activity activity, @Nullable AppCompatCallback callback)
```

Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with `activity`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | The activity linked to the returned instance. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback` | An optional callback for AppCompat specific events |

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static @NonNull AppCompatDelegate create(@NonNull Dialog dialog, @Nullable AppCompatCallback callback)
```

Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with `dialog`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Dialog.html dialog` | The dialog to be linked to the returned instance instead of an activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback` | An optional callback for AppCompat specific events |

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static @NonNull AppCompatDelegate create(
    @NonNull Context context,
    @NonNull Activity activity,
    @Nullable AppCompatCallback callback
)
```

Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with a `context` and hosted by an `Activity`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The context of the associated activity |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity` | The activity to be linked to the returned instance |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback` | An optional callback for AppCompat specific events |

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static @NonNull AppCompatDelegate create(
    @NonNull Context context,
    @NonNull Window window,
    @Nullable AppCompatCallback callback
)
```

Create an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate` to use with a `context` and a `window`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The context of the associated window |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Window.html window` | The window to be linked to the returned instance instead of an activity. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/AppCompatCallback callback` | An optional callback for AppCompat specific events |

### createView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract View createView(
    @Nullable View parent,
    String name,
    @NonNull Context context,
    @NonNull AttributeSet attrs
)
```

This should be called from a `https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html` in order to return tint-aware widgets.

This is only needed if you are using your own `https://developer.android.com/reference/android/view/LayoutInflater.html` factory, and have therefore not installed the default factory via `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#installViewFactory()`.

### findViewById

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract @Nullable T <T extends View> findViewById(@IdRes int id)
```

Finds a view that was identified by the id attribute from the XML that was processed in `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#onCreate(android.os.Bundle)`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html T` | The view if found or null otherwise. |

### getApplicationLocales

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.6.0)

```
@AnyThread
public static @NonNull LocaleListCompat getApplicationLocales()
```

Returns application locales for the calling app as a `https://developer.android.com/reference/androidx/core/os/LocaleListCompat`.

Returns a `https://developer.android.com/reference/androidx/core/os/LocaleListCompat#getEmptyLocaleList()` if no app-specific locales are set.

**Note: This API only work at AppCompatDelegate and it should always be called after Activity.onCreate().**

### getContextForDelegate

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.6.0)

```
public @Nullable Context getContextForDelegate()
```

Returns the context for the current delegate.

### getDefaultNightMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static int getDefaultNightMode()
```

Returns the default night mode.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` |   |

### getDrawerToggleDelegate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract @Nullable ActionBarDrawerToggle.Delegate getDrawerToggleDelegate()
```

Returns an `https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle.Delegate` which can be returned from your Activity if it implements `https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle.DelegateProvider`.

### getLocalNightMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public int getLocalNightMode()
```

Returns the night mode previously set via `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getLocalNightMode()`.

### getMenuInflater

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract MenuInflater getMenuInflater()
```

Return the value of this call from your `https://developer.android.com/reference/android/app/Activity.html#getMenuInflater()`

### getSupportActionBar

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract @Nullable ActionBar getSupportActionBar()
```

Support library version of `https://developer.android.com/reference/android/app/Activity.html#getActionBar()`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/app/ActionBar` | AppCompat's action bar, or null if it does not have one. |

### hasWindowFeature

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract boolean hasWindowFeature(int featureId)
```

Query for the availability of a certain feature.

This should be called instead of `https://developer.android.com/reference/android/view/Window.html#hasFeature(int)`.

| Parameters |
|---|---|
| `int featureId` | The feature ID to check |

| Returns |
|---|---|
| `boolean` | true if the feature is enabled, false otherwise. |

### installViewFactory

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void installViewFactory()
```

Installs AppCompat's `https://developer.android.com/reference/android/view/LayoutInflater.html` Factory so that it can replace the framework widgets with compatible tinted versions. This should be called before `super.onCreate()` as so:

```
protected void onCreate(Bundle savedInstanceState) {
    getDelegate().installViewFactory();
    getDelegate().onCreate(savedInstanceState);
    super.onCreate(savedInstanceState);

    // ...
}
```
If you are using your own `https://developer.android.com/reference/android/view/LayoutInflater.Factory.html` or `https://developer.android.com/reference/android/view/LayoutInflater.Factory2.html` then you can omit this call, and instead call `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#createView(android.view.View,java.lang.String,android.content.Context,android.util.AttributeSet)` from your factory to return any compatible widgets.

### invalidateOptionsMenu

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void invalidateOptionsMenu()
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#invalidateOptionsMenu()`} or `https://developer.android.com/reference/androidx/fragment/app/FragmentActivity#supportInvalidateOptionsMenu()`.

### isCompatVectorFromResourcesEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static boolean isCompatVectorFromResourcesEnabled()
```

Returns whether vector drawables on older platforms (\< API 21) can be accessed from within resources.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setCompatVectorFromResourcesEnabled(boolean)` |   |

### isHandleNativeActionModesEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract boolean isHandleNativeActionModesEnabled()
```

Returns whether AppCompat handles any native action modes itself.

| Returns |
|---|---|
| `boolean` | true if AppCompat should handle native action modes. |

### onConfigurationChanged

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onConfigurationChanged(Configuration newConfig)
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration)`

### onCreate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onCreate(Bundle savedInstanceState)
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)`.

This should be called before `super.onCreate()` as so:

```
protected void onCreate(Bundle savedInstanceState) {
    getDelegate().onCreate(savedInstanceState);
    super.onCreate(savedInstanceState);
    // ...
}
```

### onDestroy

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onDestroy()
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onDestroy()`

### onPostCreate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onPostCreate(Bundle savedInstanceState)
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onPostCreate(android.os.Bundle)`

### onPostResume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onPostResume()
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onPostResume()`

### onSaveInstanceState

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onSaveInstanceState(Bundle outState)
```

Allows AppCompat to save instance state.

### onStart

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onStart()
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onStart()` Activity.onStart()}

### onStop

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void onStop()
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onStop()`

### requestWindowFeature

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract boolean requestWindowFeature(int featureId)
```

Enable extended window features. This should be called instead of `https://developer.android.com/reference/android/app/Activity.html#requestWindowFeature(int)` or `https://developer.android.com/reference/android/view/Window.html#requestFeature(int)`.

| Parameters |
|---|---|
| `int featureId` | The desired feature as defined in `https://developer.android.com/reference/android/view/Window.html`. |

| Returns |
|---|---|
| `boolean` | Returns true if the requested feature is supported and now enabled. |

### setApplicationLocales

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.6.0)

```
public static void setApplicationLocales(@NonNull LocaleListCompat locales)
```

Sets the current locales for the calling app.

If this method is called after any host components with attached `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate`s have been 'created', a `https://developer.android.com/reference/android/os/LocaleList.html` configuration change will occur in each. This may result in those components being recreated, depending on their manifest configuration.

This method accepts `https://developer.android.com/reference/androidx/core/os/LocaleListCompat` as an input parameter.

Apps should continue to read Locales via their in-process `https://developer.android.com/reference/android/os/LocaleList.html`s.

Pass a `https://developer.android.com/reference/androidx/core/os/LocaleListCompat#getEmptyLocaleList()` to reset to the system locale.

**Note: This API should always be called after Activity.onCreate(), apart from any exceptions explicitly mentioned in this documentation.**

On API level 33 and above, this API will handle storage automatically.

For API levels below that, the developer has two options:

- They can opt-in to automatic storage handled through the library. They can do this by adding a special metaData entry in their `AndroidManifest.xml`, similar to :

  ```
      <service
          android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
          android:enabled="false"
          android:exported="false">
          <meta-data
              android:name="autoStoreLocales"
              android:value="true" />
      </service>
  ```
  They should be mindful that this will cause a blocking diskRead and diskWrite strictMode violation, and they might need to suppress it at their end.
- The second option is that they can choose to handle storage themselves. In order to do so they must use this API to initialize locales during app-start up and provide their stored locales. In this case, API should be called before Activity.onCreate() in the activity lifecycle, e.g. in attachBaseContext(). **Note: Developers should gate this to API versions \<33.**

  **This API should be called after Activity.onCreate() for all other cases.**

When the application using this API with API versions \<33 updates to a version \>= 33, then there can be two scenarios for this transition:

- If the developer has opted-in for autoStorage then the locales will be automatically synced to the framework. Developers must specify android:enabled="false" for the AppLocalesMetadataHolderService as shown in the meta-data entry above.
- If the developer has not opted-in for autoStorage then they will need to handle this transition on their end.

**Note: This API work with the AppCompatActivity context, not for others context, for Android 12 (API level 32) and earlier. If there is a requirement to get the localized string which respects the per-app locale in non-AppCompatActivity context, please consider using `https://developer.android.com/reference/androidx/core/content/ContextCompat#getString(android.content.Context,int)` or `https://developer.android.com/reference/androidx/core/content/ContextCompat#getContextForLanguage(android.content.Context)`.**

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/os/LocaleListCompat locales` | a list of locales. |

### setCompatVectorFromResourcesEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static void setCompatVectorFromResourcesEnabled(boolean enabled)
```

Sets whether vector drawables on older platforms (\< API 21) can be used within `https://developer.android.com/reference/android/graphics/drawable/DrawableContainer.html` resources.

When enabled, AppCompat can intercept some drawable inflation from the framework, which enables implicit inflation of vector drawables within `https://developer.android.com/reference/android/graphics/drawable/DrawableContainer.html` resources. You can then use those drawables in places such as `android:src` on `https://developer.android.com/reference/android/widget/ImageView.html`, or `android:drawableLeft` on `https://developer.android.com/reference/android/widget/TextView.html`. Example usage:

```
<selector xmlns:android="...">
    <item android:state_checked="true"
          android:drawable="@drawable/vector_checked_icon" />
    <item android:drawable="@drawable/vector_icon" />
</selector>

<TextView
        ...
        android:drawableLeft="@drawable/vector_state_list_icon" />
```

This feature defaults to disabled, since enabling it can cause issues with memory usage, and problems updating `https://developer.android.com/reference/android/content/res/Configuration.html` instances. If you update the configuration manually, then you probably do not want to enable this. You have been warned.

Even with this disabled, you can still use vector resources through `https://developer.android.com/reference/androidx/appcompat/widget/AppCompatImageView#setImageResource(int)` and its `app:srcCompat` attribute. They can also be used in anything which AppCompat inflates for you, such as menu resources.

Please note: this only takes effect in Activities created after this call.

### setContentView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setContentView(@LayoutRes int resId)
```

Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(int)`}

### setContentView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setContentView(View v)
```

Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View)`}

### setContentView

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setContentView(View v, ViewGroup.LayoutParams lp)
```

Should be called instead of `https://developer.android.com/reference/android/app/Activity.html#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)`}

### setDefaultNightMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public static void setDefaultNightMode(int mode)
```

Sets the default night mode. This is the default value used for all components, but can be overridden locally via `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)`.

This is the primary method to control the DayNight functionality, since it allows the delegates to avoid unnecessary recreations when possible.

If this method is called after any host components with attached `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate`s have been 'created', a `uiMode` configuration change will occur in each. This may result in those components being recreated, depending on their manifest configuration.

Defaults to `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#MODE_NIGHT_FOLLOW_SYSTEM()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setLocalNightMode(int)` |   |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getDefaultNightMode()` |   |

### setHandleNativeActionModesEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setHandleNativeActionModesEnabled(boolean enabled)
```

Whether AppCompat handles any native action modes itself.

This methods only takes effect on `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#ICE_CREAM_SANDWICH` and above.

| Parameters |
|---|---|
| `boolean enabled` | whether AppCompat should handle native action modes. |

### setLocalNightMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setLocalNightMode(int mode)
```

Override the night mode used for this delegate's host component.

When setting a mode to be used across an entire app, the `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` method is preferred.

If this is called after the host component has been created, a `uiMode` configuration change will occur, which may result in the component being recreated.

It is not recommended to use this method on a delegate attached to a `https://developer.android.com/reference/android/app/Dialog.html`. Dialogs use the host Activity as their context, resulting in the dialog's night mode overriding the Activity's night mode.

**Note:** This method is not recommended for use on devices running SDK 16 or earlier, as the specified night mode configuration may leak to other activities. Instead, consider using `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` to specify an app-wide night mode.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getLocalNightMode()` |   |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)` |   |

### setOnBackInvokedDispatcher

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.6.0)

```
@CallSuper
@RequiresApi(value = 33)
public void setOnBackInvokedDispatcher(@Nullable OnBackInvokedDispatcher dispatcher)
```

Sets the `https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html` for handling system back for Android SDK 33 and above.

If the delegate is hosted by an `https://developer.android.com/reference/android/app/Activity.html`, the default dispatcher is obtained via `https://developer.android.com/reference/android/app/Activity.html#getOnBackInvokedDispatcher()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/window/OnBackInvokedDispatcher.html dispatcher` | the OnBackInvokedDispatcher to be set on this delegate, or `null` to use the default dispatcher |

### setSupportActionBar

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setSupportActionBar(@Nullable Toolbar toolbar)
```

Set a `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` to act as the `https://developer.android.com/reference/androidx/appcompat/app/ActionBar` for this delegate.

When set to a non-null value the `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#getSupportActionBar()` ()} method will return an `https://developer.android.com/reference/androidx/appcompat/app/ActionBar` object that can be used to control the given toolbar as if it were a traditional window decor action bar. The toolbar's menu will be populated with the Activity's options menu and the navigation button will be wired through the standard `https://developer.android.com/reference/android/R.id.html#home` menu select action.

In order to use a Toolbar within the Activity's window content the application must not request the window feature `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#FEATURE_SUPPORT_ACTION_BAR()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | Toolbar to set as the Activity's action bar, or `null` to clear it |

### setTheme

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public void setTheme(@StyleRes int themeResId)
```

This should be called from `https://developer.android.com/reference/android/app/Activity.html#setTheme(int)` to notify AppCompat of what the current theme resource id is.

### setTitle

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract void setTitle(@Nullable CharSequence title)
```

Should be called from `https://developer.android.com/reference/android/app/Activity.html#onTitleChanged(java.lang.CharSequence, int)`}

### startSupportActionMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
public abstract @Nullable ActionMode startSupportActionMode(@NonNull ActionMode.Callback callback)
```

Start an action mode.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback callback` | Callback that will manage lifecycle events for this context mode |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/appcompat/view/ActionMode` | The ContextMode that was started, or null if it was canceled |