728x90
Context의 종류
안드로이드에는 두 종류의 context가 있습니다.
Applicaiton context : 어플리케이션 자체와 연동되는 것이므로, 어플리케이션의 life cycle이 지속되는 동안 동일한 객체입니다. 즉, 어플리케이션을 종료 후 다시 실행시킬때에만 바뀌는 것이지요.
Activity context : 액티비티와 연동된 것이므로, 그 액티비티를 파괴시키고 다시 시작시키면 activity context도 바뀝니다(한 개의 어플리케이션 내에는 여러 액티비티를 넣을 수 있지요).
this와 getApplicationContext()의 차이점
this :activity의 context
getApplicationContext() : application의 context
getBaseContext(), getApplication() ?
this = getBaseContext() = Activity Context
getApplicationContext() = getApplication() = Application Context
728x90
'Android > 개념 및 정보' 카테고리의 다른 글
[Android] Realm Database 첫 시작(with kotlin) (2) | 2020.12.05 |
---|---|
Android Studio 4.1 업데이트, 새로운 기능과 변경사항 (2) | 2020.10.18 |
[SurfaceView] SurfaceView란, 간단 사용법 (0) | 2020.07.17 |
[Gradle - dependency] implementation과 api의 차이점 (0) | 2020.07.17 |
Bazel이란 무엇인가 (0) | 2020.07.14 |
댓글