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
?
Asked
Active
Viewed 1.6k times
59
-
3And also what is the difference between `ComponentActivity` in **androidx.activity** package vs **androidx.core.app** package? – Mahozad Sep 19 '21 at 16:44
-
You cannot access it as it is marked with library-level access annotation – Joseph Wambura Apr 22 '22 at 08:59
1 Answers
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 Fragment
s then use AppCompatActivity
.
Note: it requires at least the AppCompat 1.3.0
version.

Gabriele Mariotti
- 320,139
- 94
- 887
- 841
-
2Can we use setLocalNightMode in Componenet activity. If so, how can we do it in compose otherwise what is the alternative. – Zakir Sheikh Feb 08 '22 at 08:20
-
1
-
-
In version `1.0.0-alpha01` https://developer.android.com/jetpack/androidx/releases/activity#1.0.0-alpha01 – Erik Ghonyan Jul 24 '23 at 09:17