안드로이드 애플리케이션의 구성
컴포넌트
- 애플리케이션은 컴포넌트로 구성된다.
- 컴포넌트는 애플리케이션을 만드는 빌딩 블록이며, 각 컴포넌트들은 하나의 독립된 엔티티로 존재하며 정해진 역할을 수행한다.
- 안드로이드 어플리케이션에는 4가지 종류의 컴포넌트가 있다.
액티비티
- 액티비티(activity)는 사용자 인터페이스 화면을 가지고, 하나의 작업을 담당하는 컴포넌트이다.
- 하나의 애플리케이션은 여러 개의 액티비티를 가질 수 있다.
- 하나의 화면 = 하나의 액티비티
- 모든 액티비티는
Activity
라는 클래스를 상속받는다.
서비스
- 서비스(service)는 백그라운드에서 실행되는 컴포넌트로, 오랫동안 실행되는 작업이나 원격 프로세스를 위한 작업을 할 때 사용된다.
- 서비스는 사용자 인터페이스 화면을 가지지 않는다.
- 모든 서비스는
Service
클래스를 상속받는다.
방송 수신자
- 방송 수신자(broadcast receiver)는 방송을 받고 반응하는 컴포넌트이다.
- 많은 방송들은 시스템에서 발생한다.
- ex) 배터리가 낮은 상태, 사진이 촬영되었다는 상태를 알리기 위해
- 방송 수신자는
BroadcastReceiver
클래스를 상속받는다.
- 일반적으로 사용자 인터페이스를 가지지 않는다.