13
Androidannotations - Application 작작작 - 작작작

Jurano강의 lec4 android_annotations_application

Embed Size (px)

Citation preview

Page 1: Jurano강의 lec4 android_annotations_application

Androidannotations - Application

작성자 - 서주리

Page 2: Jurano강의 lec4 android_annotations_application

Application Class 란 ?

Android 에서는 컴포넌트 사이에서

공동으로 멤버들을 사용할 수 있게 해주는

편리한 공유 클래스를 제공합니다 .

그게 바로 Application Class!

참고 사이트 - http://arabiannight.tistory.com/316

Page 3: Jurano강의 lec4 android_annotations_application

Application Class 란 ?

앞서 말한 것처럼 어플리케이션 사이의 컴포넌트들이

공동으로 사용할 수 있기 때문에

공통되게 사용하는 내용을 작성해주면

어디서든 context 를 이용한 접근이 가능 합니다 .

Page 4: Jurano강의 lec4 android_annotations_application

Application Class 란 ?

Application 생명 주기

• onCreate :  어플리케이션이 생성될 때 호출 됨 . 모든 상태변수와 리소스를 초기화

• onTerminate :  어플리케이션 객체가 종료될 때 호출되는데 항상 보증하지는 않음

• onLowMemory :  시스템이 리소스가 부족할 때 발생

• onConfigurationChanged :  어플리케이션은 구성변경을 위해 재시작하지 않으므로

변경이 필요하다면 이곳에서 handler 를 재정의 하면 됨 .

Page 5: Jurano강의 lec4 android_annotations_application

Application Class 란 ?일반적으로 사용 했을 경우 ,

1. Application Class 를

상속받는 클래스를

만듭니다 .

Page 6: Jurano강의 lec4 android_annotations_application

Application Class 란 ?일반적으로 사용 했을 경우 ,

2. AndroidManifest.xml 에 Application Class name 을 추가 합니다 .

Page 7: Jurano강의 lec4 android_annotations_application

Application Class 란 ?일반적으로 사용 했을 경우 ,

3. 어플리케이션 내의 컴포넌트들 사이에서

context 를 이용한 접근을 하여 사용한다 . (Data 공유 ) – 전역변수 처럼

Page 8: Jurano강의 lec4 android_annotations_application

AndroidAnnotaions –

Application 사용하기1. @EApplication Annotation 을 써주고

2. 원하는 컴포넌트에서 @App Annotation 을 써주면 끝 !

Page 9: Jurano강의 lec4 android_annotations_application

AndroidAnnotaions –

Application 사용하기

3. 물론 , AndroidManifest 의 Application name 을 추가해주어야 한다 .

generated code 를 사용하기 때문에 언더바 !

Page 10: Jurano강의 lec4 android_annotations_application

AndroidAnnotaions –

Application 사용하기

또한 , Application Class 내부에서도

어딘가에 연관된 View 를

제외하고는

대부분의 AA annotations 를

사용 가능하다 ^_^

Page 11: Jurano강의 lec4 android_annotations_application

AndroidAnnotaions –

Application 사용하기AndroidAnnotations 가 generate 한 코드를 봐보자 !

우리가 딱 한 줄로 썼던 코드가

이렇게 구성되어있다 !( 똑똑하다 !)

Page 12: Jurano강의 lec4 android_annotations_application

AndroidAnnotaions –

Application 사용하기

Activity 에서 @App Annotation 을 써준 generated code 는 아래와 같다 .

init 함수 내부에서 아주 잘 불리고 있는 것을 확인할 수 있다 ^_^

Page 13: Jurano강의 lec4 android_annotations_application

Thank you