IT/Android

1. Activity Life Cycle(Activity 수명 주기) 및 Log 남기기

바바옄 2015. 6. 22. 13:42
반응형

Log 사용법

 

 

 

 

Activity Life Cycle 

 

 

 

MainActivity.java

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.ktds.mylifecycle;
 
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.widget.Toast;
 
 
public class MainActivity extends ActionBarActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        Toast.makeText(this,"onCreate 실행 됨",Toast.LENGTH_SHORT).show();
 
        // tag, message
        Log.d("LC","onCreate 실행 됨");
    }
 
    @Override
    protected void onStart() {
        super.onStart();
 
        Toast.makeText(this,"onStart 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onStart 실행 됨");
 
    }
 
    @Override
    protected void onResume() {
        super.onResume();
 
        Toast.makeText(this,"onResume 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onResume 실행 됨");
 
    }
 
    @Override
    protected void onRestart() {
        super.onRestart();
 
        Toast.makeText(this,"onRestart 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onRestart 실행 됨");
 
    }
 
    @Override
    protected void onPause() {
        super.onPause();
 
        Toast.makeText(this,"onPause 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onPause 실행 됨");
 
    }
 
    @Override
    protected void onStop() {
        super.onStop();
 
        Toast.makeText(this,"onStop 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onStop 실행 됨");
 
    }
 
    @Override
    protected void onDestroy() {
        super.onDestroy();
 
        Toast.makeText(this,"onDestroy 실행 됨",Toast.LENGTH_SHORT).show();
        Log.d("LC""onDestroy 실행 됨");
 
    }
}
 
cs

 

 

App 실행

 

onCreate -> onStart -> onPause

 

back button 클릭

 

onPause -> onStop

 

재실행

 

onRestart -> onPause

 

Home Button 클릭

 

onStop -> onDestory

 

 

      

 

 

       

반응형

'IT > Android' 카테고리의 다른 글

2. Activity를 이용한 계산기  (0) 2015.06.22
2. Activity Life Cycle(Activity 수명 주기)  (0) 2015.06.22
1. Activity를 이용한 계산기  (0) 2015.06.22
Layout  (0) 2015.06.22
ListView  (0) 2015.06.18