Android 12 Developer Preview is here! Try it out, and give us your feedback!

AppCompatDelegate

abstract class AppCompatDelegate
kotlin.Any
   ↳ androidx.appcompat.app.AppCompatDelegate

This class represents a delegate which you can use to extend AppCompat's support to any android.app.Activity.

When using an AppCompatDelegate, you should call the following methods instead of the android.app.Activity method of the same name:

The following methods should be called from the android.app.Activity method of the same name:

An Activity can only be linked with one AppCompatDelegate instance, therefore the instance returned from create(Activity, AppCompatCallback) should be retained until the Activity is destroyed.

Summary

Constants
static Int

Flag for specifying the behavior of action modes when an Action Bar is not present.

static Int

Flag for enabling the support Action Bar.

static Int

Flag for requesting an support Action Bar that overlays window content.

static Int

static Int

Night mode which uses a dark mode when the system's 'Battery Saver' feature is enabled, otherwise it uses a 'light mode'.

static Int

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

static Int

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

static Int

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

static Int

An unspecified mode for night mode.

static Int

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

Public methods
abstract Unit

Should be called instead of Activity#addContentView(android.view.View, android.view.ViewGroup.LayoutParams)}

abstract Boolean

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

open Unit

open Context
attachBaseContext2(@NonNull context: Context)

Should be called from Activity#attachBaseContext(Context).

open static AppCompatDelegate
create(@NonNull activity: Activity, @Nullable callback: AppCompatCallback?)

Create an androidx.appcompat.app.AppCompatDelegate to use with activity.

open static AppCompatDelegate
create(@NonNull dialog: Dialog, @Nullable callback: AppCompatCallback?)

Create an androidx.appcompat.app.AppCompatDelegate to use with dialog.

open static AppCompatDelegate
create(@NonNull context: Context, @NonNull window: Window, @Nullable callback: AppCompatCallback?)

Create an androidx.appcompat.app.AppCompatDelegate to use with a context and a window.

open static AppCompatDelegate
create(@NonNull context: Context, @NonNull activity: Activity, @Nullable callback: AppCompatCallback?)

Create an androidx.appcompat.app.AppCompatDelegate to use with a context and hosted by an Activity.

abstract View!
createView(@Nullable parent: View?, name: String!, @NonNull context: Context, @NonNull attrs: AttributeSet)

This should be called from a LayoutInflater.Factory2 in order to return tint-aware widgets.

abstract T?
findViewById(@IdRes id: Int)

Finds a view that was identified by the id attribute from the XML that was processed in onCreate.

open static Int

Returns the default night mode.

abstract ActionBarDrawerToggle.Delegate?