Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.


open class ComponentActivity : ComponentActivity, ContextAware, LifecycleOwner, ViewModelStoreOwner, HasDefaultViewModelProviderFactory, SavedStateRegistryOwner, OnBackPressedDispatcherOwner, ActivityResultRegistryOwner, ActivityResultCaller

Base class for activities that enables composition of higher level components.

Rather than all functionality being built directly into this class, only the minimal set of lower level building blocks are included. Higher level components can then be used as needed without enforcing a deep Activity class hierarchy or strong coupling between components.


Public constructors

Default constructor for ComponentActivity.

<init>(@LayoutRes contentLayoutId: Int)

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

Public methods
open Unit
addContentView(view: View!, params: LayoutParams!)


Add a new OnContextAvailableListener for receiving a callback for when this class is associated with a android.content.Context.


Get the ActivityResultRegistry associated with this activity.

open ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

open Any?

Return the value previously returned from onRetainCustomNonConfigurationInstance().

open Lifecycle

Returns the Lifecycle of the provider.


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


open ViewModelStore

Returns the ViewModelStore associated with this activity

open Unit

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

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

open Any?

Use this instead of onRetainNonConfigurationInstance().


Retain all appropriate non-config state.

open Context?

registerForActivityResult(@NonNull contract: ActivityResultContract<I, O>, @NonNull registry: ActivityResultRegistry, @NonNull callback: ActivityResultCallback<O>)

registerForActivityResult(@NonNull contract: ActivityResultContract<I, O>, @NonNull callback: ActivityResultCallback<O>)


open Unit

open Unit
setContentView(@LayoutRes layoutResID: Int)

open Unit

open Unit
setContentView(view: View!, params: LayoutParams!)

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

open Unit
startActivityForResult(intent: Intent!, requestCode: Int, @Nullable options: Bundle?)

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

open Unit
startIntentSenderForResult(intent: IntentSender!, requestCode: Int, @Nullable fillInIntent: Intent?, flagsMask: Int, flagsValues: Int, extraFlags: Int, @Nullable options: Bundle?)

Protected methods
open Unit
onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?)

open Unit
onCreate(@Nullable savedInstanceState: Bundle?)

If your ComponentActivity is annotated with ContentView, this will call setContentView(int) for you.

open Unit
onSaveInstanceState(@NonNull outState: Bundle)

Extension functions
From androidx.compose.ui.platform
ComponentActivity.setContent(parent: CompositionReference = Recomposer.current(), content: () -> Unit)

Composes the given composable into the given activity.

From androidx.activity