AppCompatActivity


class AppCompatActivity : FragmentActivity, AppCompatCallback, TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider


Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features include:

Note that every activity that extends this class has to be themed with Theme.AppCompat or a theme that extends that theme.

Summary

Public constructors

Default constructor for AppCompatActivity.

Alternate constructor that can be used to provide a default layout that will be inflated as part of super.onCreate(savedInstanceState).

Public functions

Unit
Unit
Boolean
T!
<T : View?> findViewById(id: @IdRes Int)
AppCompatDelegate
ActionBarDrawerToggle.Delegate?
MenuInflater
Resources!
ActionBar?

Support library version of getActionBar.

Intent?

Obtain an android.content.Intent that will launch an explicit target activity specified by sourceActivity's PARENT_ACTIVITY element in the application's manifest.

Unit
Unit

{@inheritDoc}

Unit
Unit

Support version of onCreateNavigateUpTaskStack.

Boolean
onKeyDown(keyCode: Int, event: KeyEvent!)
Boolean
onMenuItemSelected(featureId: Int, item: MenuItem)
Boolean
onMenuOpened(featureId: Int, menu: Menu!)

Please note: AppCompat uses its own feature id for the action bar: FEATURE_SUPPORT_ACTION_BAR.

Unit
onPanelClosed(featureId: Int, menu: Menu)

Please note: AppCompat uses its own feature id for the action bar: FEATURE_SUPPORT_ACTION_BAR.

Unit

Support version of onPrepareNavigateUpTaskStack.

Unit

Notifies the activity that a support action mode has finished.

Unit

Notifies the Activity that a support action mode has been started.

Unit

This function is deprecated.

Use onContentChanged instead.

Boolean

This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.

ActionMode?

Called when a support action mode is being started for this window.

Unit
Unit
setContentView(layoutResID: @LayoutRes Int)
Unit
Unit
Unit

Set a Toolbar to act as the androidx.appcompat.app.ActionBar for this Activity window.

Unit

This function is deprecated.

Progress bars are no longer provided in AppCompat.

Unit

This function is deprecated.

Progress bars are no longer provided in AppCompat.

Unit

This function is deprecated.

Progress bars are no longer provided in AppCompat.

Unit

This function is deprecated.

Progress bars are no longer provided in AppCompat.

Unit
ActionMode?

Start an action mode.

Unit

This function is deprecated.

Call invalidateOptionsMenu directly.

Unit

Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process. upIntent will have the flag FLAG_ACTIVITY_CLEAR_TOP set by this method, along with any others required for proper up navigation as outlined in the Android Design Guide.

Boolean

Enable extended support library window features.

Boolean

Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent.

Protected functions

Unit
Unit

Destroy all fragments.

Unit

Called when the locales have been changed.

Unit

Called when the night mode has changed.

Unit
onPostCreate(savedInstanceState: Bundle?)
Unit

Dispatch onResume() to fragments.

Unit

Dispatch onStart() to all fragments.

Unit

Dispatch onStop() to all fragments.

Unit
onTitleChanged(title: CharSequence!, color: Int)

Extension functions

Unit

Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController.

Unit
AppCompatActivity.setupActionBarWithNavController(
    navController: NavController,
    drawerLayout: DrawerLayout?
)

Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController.

Inherited Constants

From android.app.Activity
From android.content.ComponentCallbacks2
From android.content.Context
const String!
ACCESSIBILITY_SERVICE = "accessibility"
const String!
ACCOUNT_SERVICE = "account"
const String!
ACTIVITY_SERVICE = "activity"
const String!
ALARM_SERVICE = "alarm"
const String!
APPWIDGET_SERVICE = "appwidget"
const String!
APP_OPS_SERVICE = "appops"
const String!
APP_SEARCH_SERVICE = "app_search"
const String!
AUDIO_SERVICE = "audio"
const String!
BATTERY_SERVICE = "batterymanager"
const Int
const Int
const Int
const Int
const Int
const Int
const Int
BIND_EXTERNAL_SERVICE = -2147483648
const Long
BIND_EXTERNAL_SERVICE_LONG = 4611686018427387904
const Int
const Int
const Int
const Int
const Int
const Int
const String!
BIOMETRIC_SERVICE = "biometric"
const String!
BLOB_STORE_SERVICE = "blob_store"
const String!
BLUETOOTH_SERVICE = "bluetooth"
const String!
BUGREPORT_SERVICE = "bugreport"
const String!
CAMERA_SERVICE = "camera"
const String!
CAPTIONING_SERVICE = "captioning"
const String!
CARRIER_CONFIG_SERVICE = "carrier_config"
const String!
CLIPBOARD_SERVICE = "clipboard"
const String!
COMPANION_DEVICE_SERVICE = "companiondevice"
const String!
CONNECTIVITY_DIAGNOSTICS_SERVICE = "connectivity_diagnostics"
const String!
CONNECTIVITY_SERVICE = "connectivity"
const String!
CONSUMER_IR_SERVICE = "consumer_ir"
const Int
const Int
const Int
const String!
CREDENTIAL_SERVICE = "credential"
const String!
CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"
const Int
const Int
const String!
DEVICE_LOCK_SERVICE = "device_lock"
const String!
DEVICE_POLICY_SERVICE = "device_policy"
const String!
DISPLAY_HASH_SERVICE = "display_hash"
const String!
DISPLAY_SERVICE = "display"
const String!
DOMAIN_VERIFICATION_SERVICE = "domain_verification"
const String!
DOWNLOAD_SERVICE = "download"
const String!
DROPBOX_SERVICE = "dropbox"
const String!
EUICC_SERVICE = "euicc"
const String!
FILE_INTEGRITY_SERVICE = "file_integrity"
const String!
FINGERPRINT_SERVICE = "fingerprint"
const String!
GAME_SERVICE = "game"
const String!
GRAMMATICAL_INFLECTION_SERVICE = "grammatical_inflection"
const String!
HARDWARE_PROPERTIES_SERVICE = "hardware_properties"
const String!
HEALTHCONNECT_SERVICE = "healthconnect"
const String!
INPUT_METHOD_SERVICE = "input_method"
const String!
INPUT_SERVICE = "input"
const String!
IPSEC_SERVICE = "ipsec"
const String!
JOB_SCHEDULER_SERVICE = "jobscheduler"
const String!
KEYGUARD_SERVICE = "keyguard"
const String!
LAUNCHER_APPS_SERVICE = "launcherapps"
const String!
LAYOUT_INFLATER_SERVICE = "layout_inflater"
const String!
LOCALE_SERVICE = "locale"
const String!
LOCATION_SERVICE = "location"
const String!
MEDIA_COMMUNICATION_SERVICE = "media_communication"
const String!
MEDIA_METRICS_SERVICE = "media_metrics"
const String!
MEDIA_PROJECTION_SERVICE = "media_projection"
const String!
MEDIA_ROUTER_SERVICE = "media_router"
const String!
MEDIA_SESSION_SERVICE = "media_session"
const String!
MIDI_SERVICE = "midi"
const Int
MODE_APPEND = 32768
const Int
const Int

This property is deprecated.

const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const String!
const String!
NFC_SERVICE = "nfc"
const String!
NOTIFICATION_SERVICE = "notification"
const String!
NSD_SERVICE = "servicediscovery"
const String!
OVERLAY_SERVICE = "overlay"
const String!
PEOPLE_SERVICE = "people"
const String!
PERFORMANCE_HINT_SERVICE = "performance_hint"
const String!
POWER_SERVICE = "power"
const String!
PRINT_SERVICE = "print"
const Int
const Int
const Int
const String!
RESTRICTIONS_SERVICE = "restrictions"
const String!
ROLE_SERVICE = "role"
const String!
SEARCH_SERVICE = "search"
const String!
SENSOR_SERVICE = "sensor"
const String!
SHORTCUT_SERVICE = "shortcut"
const String!
STATUS_BAR_SERVICE = "statusbar"
const String!
STORAGE_SERVICE = "storage"
const String!
STORAGE_STATS_SERVICE = "storagestats"
const String!
SYSTEM_HEALTH_SERVICE = "systemhealth"
const String!
TELECOM_SERVICE = "telecom"
const String!
TELEPHONY_IMS_SERVICE = "telephony_ims"
const String!
const String!
TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"
const String!
TEXT_CLASSIFICATION_SERVICE = "textclassification"
const String!
const String!
TV_INPUT_SERVICE = "tv_input"
const String!
TV_INTERACTIVE_APP_SERVICE = "tv_interactive_app"
const String!
UI_MODE_SERVICE = "uimode"
const String!
USAGE_STATS_SERVICE = "usagestats"
const String!
USB_SERVICE = "usb"
const String!
USER_SERVICE = "user"
const String!
VIBRATOR_MANAGER_SERVICE = "vibrator_manager"
const String!
VIBRATOR_SERVICE = "vibrator"

This property is deprecated.

const String!
VIRTUAL_DEVICE_SERVICE = "virtualdevice"
const String!
VPN_MANAGEMENT_SERVICE = "vpn_management"
const String!
WALLPAPER_SERVICE = "wallpaper"
const String!
WIFI_AWARE_SERVICE = "wifiaware"
const String!
WIFI_P2P_SERVICE = "wifip2p"
const String!
const String!
WIFI_SERVICE = "wifi"
const String!
WINDOW_SERVICE = "window"

Inherited functions

From android.app.Activity
Unit
Unit
Unit
PendingIntent!
createPendingResult(requestCode: Int, data: Intent!, flags: Int)
Unit

This function is deprecated.

Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
dump(
    prefix: String!,
    fd: FileDescriptor!,
    writer: PrintWriter!,
    args: Array<String!>!
)
Unit

This function is deprecated.

Boolean
Unit
Unit
finishActivity(requestCode: Int)
Unit
finishActivityFromChild(child: Activity!, requestCode: Int)

This function is deprecated.

Unit
Unit
Unit
Unit

This function is deprecated.

ActionBar!
Application!
ComponentName!
String!
Int
ComponentName!
Scene!
TransitionManager!
View!
FragmentManager!

This function is deprecated.

Intent!
Any!
String!
Int
LayoutInflater!
LoaderManager!

This function is deprecated.

String!
Int
MediaController!
OnBackInvokedDispatcher!
Activity!
Intent!
SharedPreferences!
Uri!
Int
SearchEvent!
SplashScreen!
Any!
Int
CharSequence!
Int
VoiceInteractor!
Int
Window!
WindowManager!
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Cursor!
managedQuery(
    uri: Uri!,
    projection: Array<String!>!,
    selection: String!,
    selectionArgs: Array<String!>!,
    sortOrder: String!
)

This function is deprecated.

Boolean
Boolean
navigateUpTo(upIntent: Intent!)
Boolean
navigateUpToFromChild(child: Activity!, upIntent: Intent!)

This function is deprecated.

Unit
Unit
Unit
onActivityReenter(resultCode: Int, data: Intent!)
Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent!)
Unit
onApplyThemeResource(theme: Resources.Theme!, resid: Int, first: Boolean)
Unit

This function is deprecated.

Unit
Unit

This function is deprecated.

Unit
onChildTitleChanged(childActivity: Activity!, title: CharSequence!)
Unit
Boolean
Unit
Unit
onCreate(savedInstanceState: Bundle!)
Unit
onCreateContextMenu(
    menu: ContextMenu!,
    v: View!,
    menuInfo: ContextMenu.ContextMenuInfo!
)
CharSequence!
Dialog!

This function is deprecated.

Unit
Boolean
Boolean
onCreatePanelMenu(featureId: Int, menu: Menu!)
View!
onCreatePanelView(featureId: Int)
Boolean
onCreateThumbnail(outBitmap: Bitmap!, canvas: Canvas!)

This function is deprecated.

View!
onCreateView(name: String!, context: Context!, attrs: AttributeSet!)
Unit
Unit
Unit
Boolean
Unit
onGetDirectActions(
    cancellationSignal: CancellationSignal!,
    callback: Consumer<(Mutable)List<DirectAction!>!>!
)
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent!)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent!)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent!)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent!)
Unit
Unit
Unit
Boolean
onMenuItemSelected(featureId: Int, item: MenuItem!)
Unit
onMultiWindowModeChanged(
    isInMultiWindowMode: Boolean,
    newConfig: Configuration!
)
Boolean
Boolean

This function is deprecated.

Unit
onNewIntent(intent: Intent!)
Boolean
Unit
Unit
onPanelClosed(featureId: Int, menu: Menu!)
Unit
Unit
onPerformDirectAction(
    actionId: String!,
    arguments: Bundle!,
    cancellationSignal: CancellationSignal!,
    resultListener: Consumer<Bundle!>!
)
Unit
onPictureInPictureModeChanged(
    isInPictureInPictureMode: Boolean,
    newConfig: Configuration!
)
Boolean
Unit
Unit
Unit
onPrepareDialog(id: Int, dialog: Dialog!)

This function is deprecated.

Unit
Boolean
Boolean
onPreparePanel(featureId: Int, view: View!, menu: Menu!)
Unit
Unit
Unit
onProvideKeyboardShortcuts(
    data: (Mutable)List<KeyboardShortcutGroup!>!,
    menu: Menu!,
    deviceId: Int
)
Uri!
Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>!,
    grantResults: IntArray!
)
Unit
Unit
onRestoreInstanceState(savedInstanceState: Bundle!)
Unit
Any!
Unit
Boolean
Unit
Unit

This function is deprecated.

Unit
Unit
onTopResumedActivityChanged(isTopResumedActivity: Boolean)
Boolean
Boolean
Unit
onTrimMemory(level: Int)
Unit
Unit
Unit

This function is deprecated.

Unit
Unit
ActionMode!
Unit
Unit
overrideActivityTransition(
    overrideType: Int,
    enterAnim: Int,
    exitAnim: Int
)
Unit
overridePendingTransition(enterAnim: Int, exitAnim: Int)

This function is deprecated.

Unit
Unit
Unit
Unit
Unit
Unit
Boolean
Unit

This function is deprecated.

Unit
DragAndDropPermissions!
Unit
requestFullscreenMode(
    request: Int,
    approvalCallback: OutcomeReceiver<Void!, Throwable!>!
)
Unit
requestPermissions(permissions: Array<String!>!, requestCode: Int)
Unit
Boolean

This function is deprecated.

Boolean
T!
<T : View?> requireViewById(id: Int)
Unit
Unit
setActionBar(toolbar: Toolbar!)
Unit
Unit
setContentView(layoutResID: Int)
Unit
Unit
Unit
Unit
setFeatureDrawable(featureId: Int, drawable: Drawable!)
Unit
setFeatureDrawableAlpha(featureId: Int, alpha: Int)
Unit
setFeatureDrawableResource(featureId: Int, resId: Int)
Unit
setFeatureDrawableUri(featureId: Int, uri: Uri!)
Unit
Unit
Unit
setInheritShowWhenLocked(inheritShowWhenLocked: Boolean)
Unit
setIntent(newIntent: Intent!)
Unit
setLocusContext(locusId: LocusId!, bundle: Bundle!)
Unit
Unit
Unit
setProgress(progress: Int)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
setRequestedOrientation(requestedOrientation: Int)
Unit
setResult(resultCode: Int)
Unit
setSecondaryProgress(secondaryProgress: Int)

This function is deprecated.

Unit
setShouldDockBigOverlays(shouldDockBigOverlays: Boolean)
Unit
setShowWhenLocked(showWhenLocked: Boolean)
Unit
Unit
Unit
setTitleColor(textColor: Int)

This function is deprecated.

Boolean
setTranslucent(translucent: Boolean)
Unit
setTurnScreenOn(turnScreenOn: Boolean)
Unit
setVisible(visible: Boolean)
Unit
Unit
setVrModeEnabled(enabled: Boolean, requestedComponent: ComponentName!)
Boolean
Boolean
Boolean
shouldUpRecreateTask(targetIntent: Intent!)
Boolean
Unit

This function is deprecated.

Boolean
showDialog(id: Int, args: Bundle!)

This function is deprecated.

Unit
ActionMode!
Unit
Unit
Unit
startActivityForResult(intent: Intent!, requestCode: Int)
Unit
startActivityFromChild(child: Activity!, intent: Intent!, requestCode: Int)

This function is deprecated.

Unit
startActivityFromFragment(
    fragment: Fragment!,
    intent: Intent!,
    requestCode: Int
)

This function is deprecated.

Boolean
startActivityIfNeeded(intent: Intent!, requestCode: Int)
Unit
startIntentSender(
    intent: IntentSender!,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)
Unit
startIntentSenderForResult(
    intent: IntentSender!,
    requestCode: Int,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)
Unit
startIntentSenderFromChild(
    child: Activity!,
    intent: IntentSender!,
    requestCode: Int,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)

This function is deprecated.

Unit
Unit
Unit

This function is deprecated.

Boolean
Unit
Unit
startSearch(
    initialQuery: String!,
    selectInitialQuery: Boolean,
    appSearchData: Bundle!,
    globalSearch: Boolean
)
Unit
Unit
Unit

This function is deprecated.

Unit
Unit
triggerSearch(query: String!, appSearchData: Bundle!)
Unit
Unit
Unit
Unit
From androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback
abstract Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>,
    grantResults: IntArray
)

Callback for the result from requesting permissions.

From androidx.activity.ComponentActivity
Unit

Adds the given MenuProvider to this MenuHost.

Unit

Add a new listener that will get a callback associated with ComponentCallbacks.onConfigurationChanged with the new Configuration.

Unit

{@inheritDoc}

Unit

Add a new listener that will get a callback associated with Activity.onMultiWindowModeChanged with the new MultiWindowModeChangedInfo.

Unit

Add a new listener that will get a callback associated with Activity.onNewIntent with the new Intent.

Unit

Add a new listener that will get a callback associated with Activity.onPictureInPictureModeChanged with the new PictureInPictureModeChangedInfo.

Unit

Add a new listener that will get a callback associated with ComponentCallbacks2.onTrimMemory with the int representing the level of trimming.

Unit

Add a new listener that will get a callback associated with Activity.onUserLeaveHint

CreationExtras!
ViewModelProvider.Factory!
FullyDrawnReporter!

Retrieve the FullyDrawnReporter that should handle the independent parts of the UI that separately report that they are fully drawn.

Any!
Lifecycle!

{@inheritDoc}

OnBackPressedDispatcher!

Retrieve the OnBackPressedDispatcher that will be triggered when onBackPressed is called.

SavedStateRegistry!
ViewModelStore!
Unit

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.

Unit

Invalidates the android.view.Menu to ensure that what is displayed matches the current internal state of the menu.

Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent!)

{@inheritDoc}

Unit

Called when the activity has detected the user's press of the back key.

Unit
onCreate(savedInstanceState: Bundle!)

{@inheritDoc}

Boolean
onCreatePanelMenu(featureId: Int, menu: Menu!)
Boolean
onMenuItemSelected(featureId: Int, item: MenuItem!)
Unit
onMultiWindowModeChanged(isInMultiWindowMode: Boolean)

{@inheritDoc}

Unit
onNewIntent(intent: Intent!)

{@inheritDoc}

Unit
onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

{@inheritDoc}

Boolean
onPreparePanel(featureId: Int, view: View!, menu: Menu!)
Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>!,
    grantResults: IntArray!
)

{@inheritDoc}

Any!

Use this instead of onRetainNonConfigurationInstance.

Any!

Retain all appropriate non-config state.

Unit
Unit
onTrimMemory(level: Int)

{@inheritDoc}

Unit

{@inheritDoc}

Context!

Get the Context if it is currently available.

ActivityResultLauncher<I!>!
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>!,
    registry: ActivityResultRegistry!,
    callback: ActivityResultCallback<O!>!
)

Register a request to start an activity for result, designated by the given contract.

Unit

Removes the given MenuProvider from this MenuHost.

Unit

Remove a previously added listener.

Unit

Remove a OnContextAvailableListener previously added via addOnContextAvailableListener.

Unit

Remove a previously added listener.

Unit

Remove a previously added listener.

Unit

Remove a previously added listener.

Unit

Remove a previously added listener.

Unit

Remove a previously added listener.

Unit
Unit
startActivityForResult(intent: Intent!, requestCode: Int)

{@inheritDoc}

Unit
startIntentSenderForResult(
    intent: IntentSender!,
    requestCode: Int,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)

{@inheritDoc}

From android.content.Context
From android.view.ContextThemeWrapper
From android.content.ContextWrapper
Boolean
bindIsolatedService(
    service: Intent!,
    flags: Int,
    instanceName: String!,
    executor: Executor!,
    conn: ServiceConnection!
)
Boolean
bindService(service: Intent!, conn: ServiceConnection!, flags: Int)
Boolean
bindServiceAsUser(
    service: Intent!,
    conn: ServiceConnection!,
    flags: Int,
    user: UserHandle!
)
Int
Int
IntArray<Int>!
checkCallingOrSelfUriPermissions(
    uris: (Mutable)List<Uri!>!,
    modeFlags: Int
)
Int
Int
checkCallingUriPermission(uri: Uri!, modeFlags: Int)
IntArray<Int>!
checkCallingUriPermissions(uris: (Mutable)List<Uri!>!, modeFlags: Int)
Int
checkPermission(permission: String!, pid: Int, uid: Int)
Int
Int
checkUriPermission(uri: Uri!, pid: Int, uid: Int, modeFlags: Int)
IntArray<Int>!
checkUriPermissions(
    uris: (Mutable)List<Uri!>!,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
Unit

This function is deprecated.

Context!
createAttributionContext(attributionTag: String!)
Context!
createConfigurationContext(overrideConfiguration: Configuration!)
Context!
createContext(contextParams: ContextParams!)
Context!
Context!
Context!
Context!
Context!
createPackageContext(packageName: String!, flags: Int)
Context!
createWindowContext(type: Int, options: Bundle!)
Array<String!>!
Boolean
Boolean
Boolean
Unit
enforceCallingOrSelfPermission(permission: String!, message: String!)
Unit
enforceCallingOrSelfUriPermission(
    uri: Uri!,
    modeFlags: Int,
    message: String!
)
Unit
enforceCallingPermission(permission: String!, message: String!)
Unit
enforceCallingUriPermission(uri: Uri!, modeFlags: Int, message: String!)
Unit
enforcePermission(permission: String!, pid: Int, uid: Int, message: String!)
Unit
enforceUriPermission(
    uri: Uri!,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String!
)
Array<String!>!
Context!
ApplicationInfo!
AttributionSource!
String!
Context!
File!
ClassLoader!
File!
ContentResolver!
File!
File!
Int
File!
getDir(name: String!, mode: Int)
Display!
File!
Array<File!>!
File!
Array<File!>!
Array<File!>!

This function is deprecated.

File!
File!
Executor!
Looper!
File!
File!
Array<File!>!
String!
String!
PackageManager!
String!
String!
ContextParams!
SharedPreferences!
getSharedPreferences(name: String!, mode: Int)
String!
getSystemServiceName(serviceClass: Class<Any!>!)
Drawable!

This function is deprecated.

Int

This function is deprecated.

Int

This function is deprecated.

Unit
grantUriPermission(toPackage: String!, uri: Uri!, modeFlags: Int)
Boolean
Boolean
Boolean
Boolean
moveDatabaseFrom(sourceContext: Context!, name: String!)
Boolean
moveSharedPreferencesFrom(sourceContext: Context!, name: String!)
FileInputStream!
FileOutputStream!
openFileOutput(name: String!, mode: Int)
SQLiteDatabase!
openOrCreateDatabase(
    name: String!,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory!
)
Drawable!

This function is deprecated.

Unit
Intent!
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
revokeUriPermission(uri: Uri!, modeFlags: Int)
Unit
Unit
Unit
sendOrderedBroadcast(intent: Intent!, receiverPermission: String!)
Unit
sendOrderedBroadcastAsUser(
    intent: Intent!,
    user: UserHandle!,
    receiverPermission: String!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
sendStickyOrderedBroadcast(
    intent: Intent!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)

This function is deprecated.

Unit
sendStickyOrderedBroadcastAsUser(
    intent: Intent!,
    user: UserHandle!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)

This function is deprecated.

Unit
setWallpaper(bitmap: Bitmap!)

This function is deprecated.

ComponentName!
Boolean
startInstrumentation(
    className: ComponentName!,
    profileFile: String!,
    arguments: Bundle!
)
ComponentName!
startService(service: Intent!)
Boolean
Unit
Unit
Unit
Unit
updateServiceGroup(conn: ServiceConnection!, group: Int, importance: Int)
From androidx.fragment.app.FragmentActivity
Unit
dump(
    prefix: String,
    fd: FileDescriptor?,
    writer: PrintWriter,
    args: Array<String!>?
)

Print the Activity's state into the given stream.

FragmentManager

Return the FragmentManager for interacting with fragments associated with this activity.

LoaderManager

This function is deprecated.

Use LoaderManager.getInstance(this).

Unit
@CallSuper
onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

{@inheritDoc}

Unit

This function is deprecated.

The responsibility for listening for fragments being attached has been moved to FragmentManager.

Unit
onCreate(savedInstanceState: Bundle?)

{@inheritDoc}

View?
onCreateView(name: String, context: Context, attrs: AttributeSet)
View?
onCreateView(
    parent: View?,
    name: String,
    context: Context,
    attrs: AttributeSet
)
Unit

Dispatch onPause() to fragments.

Unit
@CallSuper
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>,
    grantResults: IntArray
)

{@inheritDoc}

Unit

Dispatch onResume() to fragments.

Unit

This is the fragment-orientated version of onResume that you can override to perform operations in the Activity at the same point where its fragments are resumed.

Unit

Hook in to note that fragment state is no longer saved.

Unit

When makeSceneTransitionAnimation was used to start an Activity, callback will be called to handle shared elements on the launched Activity.

Unit

When makeSceneTransitionAnimation was used to start an Activity, listener will be called to handle shared elements on the launching Activity.

Unit
startActivityFromFragment(
    fragment: Fragment,
    intent: Intent,
    requestCode: Int
)

Called by Fragment.startActivityForResult() to implement its behavior.

Unit
startActivityFromFragment(
    fragment: Fragment,
    intent: Intent,
    requestCode: Int,
    options: Bundle?
)

Called by Fragment.startActivityForResult() to implement its behavior.

Unit
startIntentSenderFromFragment(
    fragment: Fragment,
    intent: IntentSender,
    requestCode: Int,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle?
)

This function is deprecated.

Fragments should use registerForActivityResult with the StartIntentSenderForResult contract.

Unit

Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.

Unit

Support library version of postponeEnterTransition that works only on API 21 and later.

Unit

Support library version of startPostponedEnterTransition that only works with API 21 and later.

Unit

This function is deprecated.

there are no longer any restrictions on permissions requestCodes.

From androidx.lifecycle.HasDefaultViewModelProviderFactory
From androidx.lifecycle.LifecycleOwner
abstract Lifecycle!
From androidx.core.view.MenuHost
abstract Unit

Adds the given MenuProvider to this MenuHost.

abstract Unit

Adds the given MenuProvider to this MenuHost.

abstract Unit
addMenuProvider(
    provider: MenuProvider,
    owner: LifecycleOwner,
    state: Lifecycle.State
)

Adds the given MenuProvider to this MenuHost once the given LifecycleOwner reaches the given Lifecycle.State.

abstract Unit

Invalidates the android.view.Menu to ensure that what is displayed matches the current internal state of the menu.

abstract Unit

Removes the given MenuProvider from this MenuHost.

From androidx.savedstate.SavedStateRegistryOwner
From androidx.lifecycle.ViewModelStoreOwner
From android.view.Window.Callback

Inherited properties

From androidx.activity.ComponentActivity
ActivityResultRegistry!

Get the ActivityResultRegistry associated with this activity.

Public constructors

AppCompatActivity

Added in 1.1.0
AppCompatActivity()

Default constructor for AppCompatActivity. All Activities must have a default constructor for API 27 and lower devices or when using the default android.app.AppComponentFactory.

AppCompatActivity

Added in 1.1.0
@ContentView
AppCompatActivity(contentLayoutId: @LayoutRes Int)

Alternate constructor that can be used to provide a default layout that will be inflated as part of super.onCreate(savedInstanceState).

This should generally be called from your constructor that takes no parameters, as is required for API 27 and lower or when using the default android.app.AppComponentFactory.

Public functions

addContentView

fun addContentView(view: View!, params: ViewGroup.LayoutParams!): Unit

closeOptionsMenu

fun closeOptionsMenu(): Unit

dispatchKeyEvent

fun dispatchKeyEvent(event: KeyEvent!): Boolean

findViewById

fun <T : View?> findViewById(id: @IdRes Int): T!

getDelegate

Added in 1.1.0
fun getDelegate(): AppCompatDelegate
Returns
AppCompatDelegate

The AppCompatDelegate being used by this Activity.

getDrawerToggleDelegate

Added in 1.7.0
fun getDrawerToggleDelegate(): ActionBarDrawerToggle.Delegate?
Returns
ActionBarDrawerToggle.Delegate?

Delegate to use for ActionBarDrawableToggles, or null if the Activity does not wish to override the default behavior.

getMenuInflater

fun getMenuInflater(): MenuInflater

getResources

fun getResources(): Resources!

getSupportActionBar

Added in 1.1.0
fun getSupportActionBar(): ActionBar?

Support library version of getActionBar.

Retrieve a reference to this activity's ActionBar.

Returns
ActionBar?

The Activity's ActionBar, or null if it does not have one.

getSupportParentActivityIntent

Added in 1.1.0
fun getSupportParentActivityIntent(): Intent?

Obtain an android.content.Intent that will launch an explicit target activity specified by sourceActivity's PARENT_ACTIVITY element in the application's manifest. If the device is running Jellybean or newer, the android:parentActivityName attribute will be preferred if it is present.

Returns
Intent?

a new Intent targeting the defined parent activity of sourceActivity

invalidateOptionsMenu

fun invalidateOptionsMenu(): Unit

onConfigurationChanged

fun onConfigurationChanged(newConfig: Configuration): Unit

{@inheritDoc}

Dispatches this call to all listeners added via addOnConfigurationChangedListener.

onContentChanged

fun onContentChanged(): Unit

onCreateSupportNavigateUpTaskStack

Added in 1.1.0
fun onCreateSupportNavigateUpTaskStack(builder: TaskStackBuilder): Unit

Support version of onCreateNavigateUpTaskStack. This method will be called on all platform versions. Define the synthetic task stack that will be generated during Up navigation from a different task.

The default implementation of this method adds the parent chain of this activity as specified in the manifest to the supplied androidx.core.app.TaskStackBuilder. Applications may choose to override this method to construct the desired task stack in a different way.

This method will be invoked by the default implementation of onNavigateUp if shouldUpRecreateTask returns true when supplied with the intent returned by getParentActivityIntent.

Applications that wish to supply extra Intent parameters to the parent stack defined by the manifest should override onPrepareSupportNavigateUpTaskStack.

Parameters
builder: TaskStackBuilder

An empty TaskStackBuilder - the application should add intents representing the desired task stack

onKeyDown

fun onKeyDown(keyCode: Int, event: KeyEvent!): Boolean

onMenuItemSelected

Added in 1.1.0
fun onMenuItemSelected(featureId: Int, item: MenuItem): Boolean

onMenuOpened

fun onMenuOpened(featureId: Int, menu: Menu!): Boolean

Please note: AppCompat uses its own feature id for the action bar: FEATURE_SUPPORT_ACTION_BAR.

onPanelClosed

fun onPanelClosed(featureId: Int, menu: Menu): Unit

Please note: AppCompat uses its own feature id for the action bar: FEATURE_SUPPORT_ACTION_BAR.

onPrepareSupportNavigateUpTaskStack

Added in 1.1.0
fun onPrepareSupportNavigateUpTaskStack(builder: TaskStackBuilder): Unit

Support version of onPrepareNavigateUpTaskStack. This method will be called on all platform versions. Prepare the synthetic task stack that will be generated during Up navigation from a different task.

This method receives the androidx.core.app.TaskStackBuilder with the constructed series of Intents as generated by onCreateSupportNavigateUpTaskStack. If any extra data should be added to these intents before launching the new task, the application should override this method and add that data here.

Parameters
builder: TaskStackBuilder

A TaskStackBuilder that has been populated with Intents by onCreateNavigateUpTaskStack.

onSupportActionModeFinished

Added in 1.7.0
@CallSuper
fun onSupportActionModeFinished(mode: ActionMode): Unit

Notifies the activity that a support action mode has finished. Activity subclasses overriding this method should call the superclass implementation.

Parameters
mode: ActionMode

The action mode that just finished.

onSupportActionModeStarted

Added in 1.7.0
@CallSuper
fun onSupportActionModeStarted(mode: ActionMode): Unit

Notifies the Activity that a support action mode has been started. Activity subclasses overriding this method should call the superclass implementation.

Parameters
mode: ActionMode

The new action mode.

onSupportContentChanged

Added in 1.1.0
Deprecated in 1.1.0
fun onSupportContentChanged(): Unit

onSupportNavigateUp

Added in 1.1.0
fun onSupportNavigateUp(): Boolean

This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.

If a parent was specified in the manifest for this activity or an activity-alias to it, default Up navigation will be handled automatically. See getSupportParentActivityIntent for how to specify the parent. If any activity along the parent chain requires extra Intent arguments, the Activity subclass should override the method onPrepareSupportNavigateUpTaskStack to supply those arguments.

See Tasks and Back Stack from the developer guide and Navigation from the design guide for more information about navigating within your app.

See the androidx.core.app.TaskStackBuilder class and the Activity methods getSupportParentActivityIntent, supportShouldUpRecreateTask, and supportNavigateUpTo for help implementing custom Up navigation.

Returns
Boolean

true if Up navigation completed successfully and this Activity was finished, false otherwise.

onWindowStartingSupportActionMode

Added in 1.7.0
fun onWindowStartingSupportActionMode(callback: ActionMode.Callback): ActionMode?

Called when a support action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all.

Parameters
callback: ActionMode.Callback

Callback to control the lifecycle of this action mode

Returns
ActionMode?

The ActionMode that was started, or null if the system should present it

openOptionsMenu

fun openOptionsMenu(): Unit

setContentView

fun setContentView(layoutResID: @LayoutRes Int): Unit

setContentView

fun setContentView(view: View!): Unit

setContentView

fun setContentView(view: View!, params: ViewGroup.LayoutParams!): Unit

setSupportActionBar

Added in 1.1.0
fun setSupportActionBar(toolbar: Toolbar?): Unit

Set a Toolbar to act as the androidx.appcompat.app.ActionBar for this Activity window.

When set to a non-null value the getActionBar method will return an 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 home menu select action.

In order to use a Toolbar within the Activity's window content the application must not request the window feature FEATURE_SUPPORT_ACTION_BAR.

Parameters
toolbar: Toolbar?

Toolbar to set as the Activity's action bar, or null to clear it

setSupportProgress

Added in 1.1.0
Deprecated in 1.1.0
fun setSupportProgress(progress: Int): Unit

setSupportProgressBarIndeterminate

Added in 1.1.0
Deprecated in 1.1.0
fun setSupportProgressBarIndeterminate(indeterminate: Boolean): Unit

setSupportProgressBarIndeterminateVisibility

Added in 1.1.0
Deprecated in 1.1.0
fun setSupportProgressBarIndeterminateVisibility(visible: Boolean): Unit

setSupportProgressBarVisibility

Added in 1.1.0
Deprecated in 1.1.0
fun setSupportProgressBarVisibility(visible: Boolean): Unit

setTheme

fun setTheme(resId: @StyleRes Int): Unit

startSupportActionMode

Added in 1.1.0
fun startSupportActionMode(callback: ActionMode.Callback): ActionMode?

Start an action mode.

Parameters
callback: ActionMode.Callback

Callback that will manage lifecycle events for this context mode

Returns
ActionMode?

The ContextMode that was started, or null if it was canceled

supportInvalidateOptionsMenu

Added in 1.1.0
fun supportInvalidateOptionsMenu(): Unit

Support library version of invalidateOptionsMenu.

Invalidate the activity's options menu. This will cause relevant presentations of the menu to fully update via calls to onCreateOptionsMenu and onPrepareOptionsMenu the next time the menu is requested.

supportNavigateUpTo

Added in 1.1.0
fun supportNavigateUpTo(upIntent: Intent): Unit

Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process. upIntent will have the flag FLAG_ACTIVITY_CLEAR_TOP set by this method, along with any others required for proper up navigation as outlined in the Android Design Guide.

This method should be used when performing up navigation from within the same task as the destination. If up navigation should cross tasks in some cases, see supportShouldUpRecreateTask.

Parameters
upIntent: Intent

An intent representing the target destination for up navigation

supportRequestWindowFeature

Added in 1.1.0
fun supportRequestWindowFeature(featureId: Int): Boolean

Enable extended support library window features.

This is a convenience for calling getWindow().requestFeature().

Parameters
featureId: Int

The desired feature as defined in android.view.Window or androidx.core.view.WindowCompat.

Returns
Boolean

Returns true if the requested feature is supported and now enabled.

supportShouldUpRecreateTask

Added in 1.1.0
fun supportShouldUpRecreateTask(targetIntent: Intent): Boolean

Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent.

If this method returns false the app can trivially call supportNavigateUpTo using the same parameters to correctly perform up navigation. If this method returns false, the app should synthesize a new task stack by using androidx.core.app.TaskStackBuilder or another similar mechanism to perform up navigation.

Parameters
targetIntent: Intent

An intent representing the target destination for up navigation

Returns
Boolean

true if navigating up should recreate a new task stack, false if the same task should be used for the destination

Protected functions

attachBaseContext

protected fun attachBaseContext(newBase: Context!): Unit

onDestroy

protected fun onDestroy(): Unit

Destroy all fragments.

onLocalesChanged

Added in 1.6.0
protected fun onLocalesChanged(locales: LocaleListCompat): Unit

Called when the locales have been changed. See applyAppLocales for more information.

Parameters
locales: LocaleListCompat

the localeListCompat which has been applied

onNightModeChanged

Added in 1.1.0
protected fun onNightModeChanged(mode: Int): Unit

Called when the night mode has changed. See applyDayNight for more information.

Parameters
mode: Int

the night mode which has been applied

onPostCreate

protected fun onPostCreate(savedInstanceState: Bundle?): Unit

onPostResume

protected fun onPostResume(): Unit

Dispatch onResume() to fragments.

onStart

protected fun onStart(): Unit

Dispatch onStart() to all fragments.

onStop

protected fun onStop(): Unit

Dispatch onStop() to all fragments.

onTitleChanged

protected fun onTitleChanged(title: CharSequence!, color: Int): Unit

Extension functions

setupActionBarWithNavController

fun AppCompatActivity.setupActionBarWithNavController(
    navController: NavController,
    configuration: AppBarConfiguration = AppBarConfiguration(navController.graph)
): Unit

Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid label).

The AppBarConfiguration you provide controls how the Navigation button is displayed.

You are responsible for calling NavController.navigateUp to handle the Navigation button. Typically this is done in AppCompatActivity.onSupportNavigateUp.

Parameters
navController: NavController

The NavController whose navigation actions will be reflected in the title of the action bar.

configuration: AppBarConfiguration = AppBarConfiguration(navController.graph)

Additional configuration options for customizing the behavior of the ActionBar

setupActionBarWithNavController

fun AppCompatActivity.setupActionBarWithNavController(
    navController: NavController,
    drawerLayout: DrawerLayout?
): Unit

Sets up the ActionBar returned by AppCompatActivity.getSupportActionBar for use with a NavController.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid label).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the ActionBar will show the drawer icon if the given drawerLayout is non null. On all other destinations, the ActionBar will show the Up button.

You are responsible for calling NavController.navigateUp to handle the Navigation button. Typically this is done in AppCompatActivity.onSupportNavigateUp.

Parameters
navController: NavController

The NavController whose navigation actions will be reflected in the title of the action bar.

drawerLayout: DrawerLayout?

The DrawerLayout that should be toggled from the Navigation button