Android LifeCycle 사용하기
사용 버전: Android Studio 4.0
사용 언어: Kotlin 1.3.72
안드로이드 LifeCycle 사용하기에 대해서 알아보겠습니다.
LifeCycle은 내부 코드의 실행과 종료를 보이는 화면의 LifeCycle에 따라서 자동으로 관리해 줍니다. 그래서 메모리 자원 고갈을 막을 수 있습니다.
그리고, 종료하지 않은 앱의 데이터를 붙잡고 있어서 다시 불러왔을 때, 새로 시작하는 것이 아니라, 이전 상태로 불러와집니다.
https://developer.android.com/jetpack/androidx/releases/lifecycle
현재, 안정화된 버전은 2.2.0입니다.
app 용 build.gradle에 아래를 정의해 줍니다.



수정 후, Sync now를 눌러줍니다.
File - Project Structure...에 들어갑니다.

Modules - Properties에 들어가서
Source Compatibility, Target Compatibility를 Java 1.8로 설정합니다.

Apply, OK를 누릅니다.
끝.
카테고리: Android
댓글
댓글 쓰기
궁금한 점은 댓글 달아주세요.
Comment if you have any questions.