Android
Context (컨텍스트)
qlyh8
2018. 7. 20. 04:08
Context
Interface to global information about an application environment
어플리케이션이 실행되기 위해서는 Context가 필요하다.
Context는 뷰와 같은 객체 생성 및 Activity나 Service, Receiver를 시작할 때 등 여러 방면으로 이용된다.
안드로이드 시스템이 Context를 제공하고, Context는 어플리케이션 실행을 위한 환경과 데이터를 담고 있다.
Context를 통해 getSystemService() 메서드로 시스템이 제공하는 정보를 얻을 수 있다.
Context 참조
1. Activity Context
- AbcActivity.this
: Activity는 Context 를 상속받기 때문에 Context의 정보를 담고 있어, Context가 필요한 곳에 Activity의 객체인 this를 넘길 수 있다.
- getBaseContext()
: 액티비티의 Context를 제공한다.
2. Application Context
Context 클래스에 getApplicationContext()로 어플리케이션의 Context를 얻을 수 있다.
참고 출처: http://uljavajoe.blogspot.com/2012/11/context.html?m=1