Activity 알아보기
Activity in Android
Activity 분석
Android에서 Activity는 여러 종류가 존재한다.
Activity의 상속 구조
android.app.Activity(최상위) <- androidx.activity.ComponentActivity <- FragmentActivity <- AppCompatActivity
1. android.app.Activity
Android 에서 가장 상위에 있는 Activity
2. androidx.activity.ComponentActivity
상위 Level의 컴포넌트를 구성할수 있는 Activity
androidx.AppCompat 의 기능을 사용하지 않고, 최신버전만 지원하고자 하거나, Compose 만으로 App 을 제작하고자 할때 사용한다.
보통은 AppCompatActivity 를 사용한다.
3. FragmentActivity
Android SDK Api level 10 이하에서 Fragment 를 사용하고자 할때 사용하는 Activity
약 10년 전에 나온 Android 버전 을 위해 사용되는데, 현재는 거의 사용할 필요가 없으므로 추가 내용은 생략
4. AppCompatActivity
Android 하위 버전을 지원하는 Activity
특정 SDK버전(예를 들어 level 11) 부터 사용가능한 기능(예를 들어 ActionBar)을 이전 버전(예를 들어 level 11 미만)에서도 사용할 수 있도록 하는 Activity
예를 들어 Android 3.0(Api level 11) 부터 Activity 는 기본적으로 Appbar 로 ActionBar 를 가지고 있다.
이 버전부터 사용되는 ActionBar 를 Api level 10 이하에서도 사용하려면 AppCompatActivity 를 사용해야 한다.