2012-12-19 8 views
1

가능한 중복 :
Android Activity Life Cycle - What are all these methods for?안드로이드 수명주기 활동

나는 menuActivity라는 주요 인 활동과 birthDate라는 또 다른 활동이있다.

응용 프로그램을 실행하면 menuActivity이 활성 상태가되고 버튼을 클릭하면 두 번째 것은 birthDate 인 활성 상태가됩니다.

내 질문은 :

첫 번째 활동은 다른 활동이 배경으로 이동 및 주요 활동은 어떤 방법을 내가 구현해야합니까,를 forground에 관해서 활성화 될 때? OnResume 또는 OnCreate 또는 무엇?

+0

관련 스레드 -. http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these -methods-for? rq = 1 – adatapost

답변

2

에서 살펴 보자.

2

활동이 다시 시작될 때 어떤 작업을 수행하려면 onResume() 안에 코드를 넣어야합니다. onResume()은 활동이 포어 그라운드로 갈 때마다 호출되는 메서드이기 때문입니다. onCreate()은 활동 기간 동안 한 번만 호출됩니다.

0

시스템의 활동이 활동 스택으로 관리됩니다. 새 활동이 시작되면 스택 상단에 배치되어 실행중인 활동이됩니다. 이전 활동은 항상 스택에서 그 아래에 남아 있으며 새 활동이 종료 될 때까지 다시 포어 그라운드로 이동하지 않습니다.

**If an activity in the foreground of the screen (at the top of the stack), it is active or running.** 

**If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.** 

**If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.** 

**If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state.** 

다음 그림은 활동 상태 중요한 경로를 보여준다

액티비티 본질적 네 가지 상태를 갖는다. 사각형 사각형은 활동이 상태간에 이동할 때 조작을 수행하도록 구현할 수있는 콜백 메소드를 나타냅니다. 색깔 타원 활동이 될 수있는 중요한 상태입니다

enter image description here