모바일 프로그래밍 공부
모바일 프로그래밍 3주차
NaZZU
2025. 3. 24. 10:47
안드로이드 앱 구성요소
component element | functino |
Activity | application의 프리젠테이션 계층 |
UI component를 화면에 표시 | |
Windows application의 Form과 동일 Function | |
Intenet Reciver | 메시지 전달 Framework |
Event handler Function | |
Sercive | UI와 관계없이 오랫동안 존재하면서 실행되는 코드 |
background로 실행 (예 : MediaPlayer) | |
Content Provider | Application data 공유 |
DB(SQLite) 연동 |
Activity
Component Element | Function |
OnCreate() | Activity가 생성될 때 처음 호출 |
리소스 초기화 | |
fincdViewById(int) 메소드 호출 : widget 검색 | |
setContentView(int) 메소드 호출 : widget 화면 출력 | |
Onstart() | Activity 화면 출력 시 호출 |
OnResume() | Activity stack 의 Top에 위치 |
Activity 화면 출력 및 입력 처리시 호출 | |
OnPause() | Activity 1 -> Activitty 2 : Activity 1의 내용 저장 |
데이터 저장, animation 중지, CPU 점유 작업 중단 등 수행 | |
OnStop() | 더이상 Activity가 stack의 Top에 위치하지 않으므로 Activity 출력 안됨 |
OnDestroy() | 시스템에서 Activity 제거 |
Foreground activity | 최상위 화면의 activity로 가장 중요한 프로세스. 메모리 부족 시 마지막으로 제거 |
Visible activity | 화면에 보이는 activity로 foreground activity가 아닌 activity |
Background activity | 화면에 보이지 않고 stop 상태의 activity 메모리 부족 시 foreground, visible activity보다 먼저 제거 onSaveInstanceState(Bundle savedInstanceState) 메소드 호출 - savedInstanceState : 중요 저장 데이터 저장 |
Empty Process |
Service, Broadcast Reciver Class와 같이 acvity, application component도 없는 프로세스 메모리 부족 시 즉시 제거 |