59

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?

Ben Cox
  • 1,393
  • 10
  • 28
Ebin Joy
  • 2,690
  • 5
  • 26
  • 39

1 Answers1

110

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.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841