로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.

Slides:



Advertisements
Similar presentations
Threads, AsyncTasks & Handlers.  Android implements Java threads & concurrency classes  Conceptual view  Parallel computations running in a process.
Advertisements

@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Presenting Lists of Data. Lists of Data Issues involved – unknown number of elements – allowing the user to scroll Data sources – most common ArrayList.
Cosc 5/4730 A little on threads and Messages: Handler class.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
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.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android - Broadcast Receivers
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
Import import android.graphics.Bitmap; import android.widget.ImageView;
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 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.
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Android and s Ken Nguyen Clayton state University 2012.
로봇을 조종하자 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) 라고 불린다.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Google map v2.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Concurrency in Android
Android Introduction Hello World
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
GUI Programming Fundamentals
Android Multi-Threading
CS499 – Mobile Application Development
Android – Event Handling
CS499 – Mobile Application Development
Android Introduction Hello World.
Android Widgets 1 7 August 2018
Android – Read/Write to External Storage
CS499 – Mobile Application Development
Picasso Revisted.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Programming Lecture 8
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
滑動 建國科技大學 資管系 饒瑞佶.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Threads, Handlers, and AsyncTasks
ארועים ומאזינים android.
Adding Components to Activity
CMPE419 Mobile Application Development
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
CIS 470 Mobile App Development
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Android Sensor Programming
Presentation transcript:

로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수

학습 목표 Message Queue Handler 2

핸들러 메시지 큐 3 큐 메시지 핸들러 루퍼

Message public int what public int arg1 public int arg2 public Object obj 4

Handler –Message obtainMessage() –Message obtainMessage(int what) –Message obtainMessage(int what, Object obj) –Message obtainMessage(int what, int arg1, int arg2) –Message obtainMessage(int what, int arg1, int arg2, Object obj) Message –static Message obtain(Handler h) –static Message obtain(Handler h, int what) –static Message obtain(Handler h, int what, Object obj) –static Message obtain(Handler h, int what, int arg1, int arg2) –static Message objtain(Handler h, int what, int arg1, int arg2, Object obj) 5

Message 6 Message msg = handler.obtainMessage(); msg.what = 0; msg.arg1 = 1; handler.sendMessage(msg); Message msg = handler.obtainMessage(0); msg.arg1 = 1; handler.sendMessage(msg); Message msg = handler.obtainMessage(0, 1, 0); handler.sendMessage(msg); Message msg = Message.obtain(handler, 0, 1, 0); handler.sendMessage(msg); Message msg = Message.obtain(handler, 0, 1, 0); msg.sendToTarget();

핸들러 7 <LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" />

핸들러 8 public class MainActivity extends Activity { private Button showButton; private TextView textView; private Handler handler = new Handler() public void handleMessage(Message msg) { switch(msg.what) { case 0: textView.setText("received: " + msg.arg1); break; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showButton = (Button)findViewById(R.id.show); textView = (TextView)findViewById(R.id.text); showButton.setOnClickListener(new OnClickListener() public void onClick(View v) { Message msg = handler.obtainMessage(); msg.what = 0; msg.arg1 = 1; handler.sendMessage(msg); } }); }

핸들러 9 public class MainActivity extends Activity { private Button showButton; private TextView textView; private Handler handler = new Handler() public void handleMessage(Message msg) { switch(msg.what) { case 0: textView.setText("received: " + msg.arg1); break; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showButton = (Button)findViewById(R.id.show); textView = (TextView)findViewById(R.id.text); showButton.setOnClickListener(new OnClickListener() public void onClick(View v) { Message msg = handler.obtainMessage(0); msg.arg1 = 1; handler.sendMessage(msg); } }); }

핸들러 10 public class MainActivity extends Activity { private Button showButton; private TextView textView; private Handler handler = new Handler() public void handleMessage(Message msg) { switch(msg.what) { case 0: textView.setText("received: " + msg.arg1); break; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showButton = (Button)findViewById(R.id.show); textView = (TextView)findViewById(R.id.text); showButton.setOnClickListener(new OnClickListener() public void onClick(View v) { Message msg = handler.obtainMessage(0, 1, 0); handler.sendMessage(msg); } }); }

핸들러 11 public class MainActivity extends Activity { private Button showButton; private TextView textView; private Handler handler = new Handler() public void handleMessage(Message msg) { switch(msg.what) { case 0: textView.setText("received: " + msg.arg1); break; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showButton = (Button)findViewById(R.id.show); textView = (TextView)findViewById(R.id.text); showButton.setOnClickListener(new OnClickListener() public void onClick(View v) { Message.obtain(handler, 0, 1, 0).sendToTarget(); } }); }

핸들러 12 public class MainActivity extends Activity { private Button showButton; private TextView textView; private Handler handler = new Handler() public void handleMessage(Message msg) { switch(msg.what) { case 0: textView.setText("received: " + msg.obj); break; } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); showButton = (Button)findViewById(R.id.show); textView = (TextView)findViewById(R.id.text); showButton.setOnClickListener(new OnClickListener() public void onClick(View v) { handler.obtainMessage(0, "test").sendToTarget(); } }); }

로봇 모니터링 13 public class MainActivity extends RobotActivity { private TextView leftProximityTextView; private TextView protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); leftProximityTextView = (TextView)findViewById(R.id.leftProximity); rightProximityTextView = (TextView)findViewById(R.id.rightProximity); public void onDeviceDataChanged(Device device, Object values, long timestamp) { int[] data; switch(device.getId()) { case Albert.SENSOR_LEFT_PROXIMITY: { data = (int[])values; leftProximityTextView.setText("Left Proximity: " + data[0]); } break; case Albert.SENSOR_RIGHT_PROXIMITY: { data = (int[])values; rightProximityTextView.setText("Right Proximity: " + data[0]); } break; }

로봇 모니터링 14 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views :15:30.216: E/JavaBinder(24444): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4924) :15:30.216:

로봇 모니터링 15 public class MainActivity extends RobotActivity { private TextView leftProximityTextView; private TextView rightProximityTextView; private Handler handler = new Handler() public void handleMessage(Message msg) { int[] values; switch(msg.what) { case Albert.SENSOR_LEFT_PROXIMITY: { values = (int[])msg.obj; leftProximityTextView.setText("Left Proximity: " + values[0] + "," + values[1] + "," + values[2] + "," + values[3]); } break; case Albert.SENSOR_RIGHT_PROXIMITY: { values = (int[])msg.obj; rightProximityTextView.setText("Right Proximity: " + values[0] + "," + values[1] + "," + values[2] + "," + values[3]); } break; } };

로봇 모니터링 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); leftProximityTextView = (TextView)findViewById(R.id.leftProximity); rightProximityTextView = (TextView)findViewById(R.id.rightProximity); public void onDeviceDataChanged(Device device, Object values, long timestamp) { handler.obtainMessage(device.getId(), values).sendToTarget(); }

로봇 모니터링 public void onDeviceDataChanged(final Device device, final Object values, long timestamp) { runOnUiThread(new Runnable() public void run() { int[] data; switch(device.getId()) { case Albert.SENSOR_LEFT_PROXIMITY: { data = (int[])values; leftProximityTextView.setText("Left Proximity: " + data[0]); } break; case Albert.SENSOR_RIGHT_PROXIMITY: { data = (int[])values; rightProximityTextView.setText("Right Proximity: " + data[0]); } break; } }); }

과제 모든 센서 출력하기 on/physical/Albert.php 18