Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Cosc 5/4730 Android: “Dynamic” data.. Saving Dynamic data. While there are a lot of ways to save data – Via the filesystem, database, etc. You can also.
Programming with Android: Activities
Android 02: Activities David Meredith
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Preferences. 2 Persistent storage Information is persistent if it is kept between one invocation of a program and the next Many programs keep user preferences.
Android Development for Different Screens and Devices Rohit Ghatol.
Data Storage: Part 1 (Preferences)
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Android Mobile computing for the rest of us.* *Prepare to be sued by Apple.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
Resources. Application Resources Resources are strings, images, and other pieces of application information that are stored and maintained (externalized)
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters.
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
Noname. Conceptual Parts States of Activities Active Pause Stop Inactive.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
CHAP 11. 액티비티와 인텐트.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Android: “Dynamic” data and Preferences data.
Android Application Lifecycle and Menus
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
CHAP 14. 프로세스와 스레드. © 2012 생능출판사 All rights reserved 다중 스레딩 하나의 애플리케이션이 동시에 여러 가지 작업을 하 는 것 이들 작업은 스레드 (thread) 라고 불린다.
Activity ANDROID CLUB Сегодня  Основные компоненты Android  Activity  Layout для Activity  Создание Activity  Launcher Activity  Activity.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Preferences. 2 Persistent storage Information is persistent if it is kept between one invocation of a program and the next Many programs keep user preferences.
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
Android Development Grant
Lab7 – Appendix.
Introduction to android
Activity and Fragment.
Java Examples Embedded System Software
Adapting to Display Orientation
GUI Programming Fundamentals
CS499 – Mobile Application Development
Android Activities An application can have one or more activities, where Each activity Represents a screen that an app present to its user Extends the.
Android 9: The Activity Lifecycle
Anatomy of an Android App and the App Lifecycle
The Android Activity Lifecycle
null, true, and false are also reserved.
CIS 470 Mobile App Development
Anatomy of an Android App and the App Lifecycle
Activity Lifecycle Fall 2012 CS2302: Programming Principles.
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
Activities and Intents
CIS 470 Mobile App Development
Activity Lifecycle.
Preferences.
Preferences.
SE4S701 Mobile Application Development
Preferences.
Activities and Fragments
Preferences.
Preferences.
Preferences.
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수

학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2

로그캣 Window > Show View > Other… 3

로그캣 4 로그 레벨 verbose, debug, info, warn, error, assert 저장로그 모두 삭제일시 멈춤

로그 레벨 verbose – 배포용 패키지 만들 때 컴파일 단계에서 빠짐 debug – 컴파일은 되지만 런타임 시에 빠짐 info warn error assert – 절대로 일어나서는 안 되는 치명적인 오류 5

로그캣 6 필터 추가 필터 삭제필터 편집

Log public static int v (String tag, String msg) public static int d (String tag, String msg) public static int i (String tag, String msg) public static int w (String tag, String msg) public static int e (String tag, String msg) public static int wtf (String tag, String msg) 7

Log 8 public class MainActivity extends RobotActivity { private Device leftWheelDevice; private Device rightWheelDevice; private MicThread thread; private static final String TAG = protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); thread = new MicThread(); thread.start(); protected void onDestroy() { Log.v(TAG, "onDestroy"); super.onDestroy(); if(thread != null) thread.cancel(); }

Log 9 private class MicThread extends Thread { private static final int FREQ = 44100; private static final int CHANNEL = AudioFormat.CHANNEL_IN_MONO; private static final int ENCODING = AudioFormat.ENCODING_PCM_16BIT; private boolean running = public void run() { Log.v(TAG, "thread started");... while(running) {... }... Log.v(TAG, "thread finished"); } void cancel() { Log.v(TAG, "cancel"); running = false; }

액티비티 생명주기 10 액티비티 상태 – 실행 – 일시 정지 – 정지

액티비티 생명주기 11

액티비티 생명주기 화면이 회전하는 경우 12 onCreate 회전 onStart onResume onSaveInstanceState onPause onStop onDestroy onRestoreInstanceState onCreate onStart onResume

액티비티 생명주기 Home 키 누른 후 앱 다시 실행 13 onCreate Home 키 onStart onResume onSaveInstanceState onPause onStop onRestart onStart onResume 다시 실행

액티비티 생명주기 Back 키를 누른 경우 14 onCreate Back 키 onStart onResume finish onPause onStop onDestroy onBackPressed

액티비티 생명주기 15 public class MainActivity extends Activity { private static final String TAG = protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); protected void onDestroy() { Log.v(TAG, "onDestroy"); super.onDestroy(); }

액티비티 생명주기 protected void onResume() { Log.v(TAG, "onResume"); super.onResume(); protected void onPause() { Log.v(TAG, "onPause"); super.onPause(); protected void onStart() { Log.v(TAG, "onStart"); super.onStart(); protected void onStop() { Log.v(TAG, "onStop"); super.onStop(); }

액티비티 생명주기 protected void onRestart() { Log.v(TAG, "onRestart"); super.onRestart(); protected void onSaveInstanceState(Bundle outState) { Log.v(TAG, "onSaveInstanceState"); super.onSaveInstanceState(outState); protected void onRestoreInstanceState(Bundle savedInstanceState) { Log.v(TAG, "onRestoreInstanceState"); super.onRestoreInstanceState(savedInstanceState); }

액티비티 생명주기 public void onBackPressed() { Log.v(TAG, "onBackPressed"); super.onBackPressed(); public void finish() { Log.v(TAG, "finish"); super.finish(); }

현재 상태 저장 19 private Button protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button)findViewById(R.id.button); button.setOnClickListener(new OnClickListener() public void onClick(View v) { button.setText(R.string.clicked); } }); }

현재 상태 저장 protected void onSaveInstanceState(Bundle outState) { Log.v(TAG, "onSaveInstanceState"); super.onSaveInstanceState(outState); String text = button.getText().toString(); outState.putString("ButtonText", text); protected void onRestoreInstanceState(Bundle savedInstanceState) { Log.v(TAG, "onRestoreInstanceState"); super.onRestoreInstanceState(savedInstanceState); button.setText(savedInstanceState.getString("ButtonText")); }

번들 (Bundle) –void putBoolean(String key, boolean value) –void putBooleanArray(String key, boolean[] value) –void putByte(String key, byte value) –void putByteArray(String key, byte[] value) –void putChar(String key, char value) –void putCharArray(String key, char[] value) –void putShort(String key, short value) –void putShortArray(String key, short[] value) –void putInt(String key, int value) –void putIntArray(String key, int[] value) –void putLong(String key, long value) –void putLongArray(String key, long[] value) –void putFloat(String key, float value) –void putFloatArray(String key, float[] value) –void putDouble(String key, double value) –void putDoubleArray(String key, double[] value) –void putString(String key, String value) –void putStringArray(String key, String[] value) –void putCharSequence(String key, CharSequence value) –void putCharSequenceArray(String key, CharSequence[] value) –… 21 Bundle Object

번들 (Bundle) –boolean getBoolean(String key) –byte getByte(String key) –char getChar(String key) –short getShort(String key) –int getInt(String key) –long getLong(String key) –float getFloat(String key) –double getDouble(String key) –String getString(String key) –CharSequence getCharSequence(String key) –… 22 –boolean getBoolean(String key, boolean defaultValue) –byte getByte(String key, byte defaultValue) –char getChar(String key, char defaultValue) –short getShort(String key, short defaultValue) –int getInt(String key, int defaultValue) –long getLong(String key, long defaultValue) –float getFloat(String key, float defaultValue) –double getDouble(String key, double defaultValue) –String getString(String key, String defaultValue) –CharSequence getCharSequence(String key, CharSequence defaultValue) –… –byte[] getByteArray(String key) –char[] getCharArray(String key) –short[] getShortArray(String key) –int[] getIntArray(String key) –long[] getLongArray(String key) –float[] getFloatArray(String key) –double[] getDoubleArray(String key) –String[] getStringArray(String key) –CharSequence[] getCharSequenceArray(String key) –…

리소스 23 layout-land layout-port

리소스 폴더 MCC(mobile country code) and MNC(mobile network code): mcc310-mnc004 Language and region: en, fr, en-rUS, fr-rFR, fr-rCA, ko Layout direction: ldrtl, ldltr Smallest width: sw320dp, sw720dp Available width: w720dp, w1024dp Available height: h720dp, h1024dp Screen size: small, normal, large, xlarge Screen aspect: long, notlong Screen orientation: port, land UI mode: car, desk, television, appliance Night mode: night, notnight Screen pixel density: ldpi, mdpi, hdpi, xhdpi, xxhdpi, nodpi, tvdpi Touchscreen type: notouch, finger Keyboard availability: keysexposed, keyshidden, keyssoft Primary text input method: nokeys, qwerty, 12key Navigation key availability: navexposed, navhidden Primary non-touch navigation method: nonav, dpad, trackball, wheel Platform version: v3, v7 24

configChanges 25 onCreate 회전 onStart onResume onConfigurationChanged <activity android:name="com.example.unit16.MainActivity" android:configChanges="orientation|screenSize" public void onConfigurationChanged(Configuration newConfig) { Log.v(TAG, "onConfigurationChanged"); super.onConfigurationChanged(newConfig); }