androidandroid-appcompatandroid-jetpack-compose

ComponentActivity vs AppCompatActivity in Android Jetpack Compose


When using Jetpack Compose, by default it extends the ComponentActivity class. But after trying some samples I switched to AppCompatActivity and everything seemed to work fine. So I wonder what the difference between these is. Do any additional features come with ComponentActivity?


Solution

  • AppCompatActivity extends FragmentActivity which extends ComponentActivity.

    ComponentActivity has all you need for a Compose-only app.
    If you need AppCompat APIs, an AndroidView which works with AppCompat or MaterialComponents theme, or you need Fragments then use AppCompatActivity.

    Note: it requires at least the AppCompat 1.3.0 version.