안드로이드2_14

Similar documents
( )부록

안드로이드기본 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 -

13ÀåÃß°¡ºÐ

[ 그림 8-1] XML 을이용한옵션메뉴설정방법 <menu> <item 항목ID" android:title=" 항목제목 "/> </menu> public boolean oncreateoptionsmenu(menu menu) { getme

[ 그림 7-1] 프로젝트 res 폴더 이미지뷰 [ 예제 7-1] 이미지뷰 1 <LinearLayout 2 ~~~~ 중간생략 ~~~~ 3 android:orientation="vertical" > 4 <ImageView

어댑터뷰

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android=" 2 xmlns:tools="

03장

9 차시고급위젯다루기 1 학습목표 날짜 / 시간과관련된위젯을배운다. 웹뷰를사용하여간단한웹브라우저기능을구현한다. 매니패스트파일의설정법을배운다. 2 확인해볼까? 3 날짜 / 시간위젯 1) 활동하기 활동개요

학습목표 선언하여디자인을하는방법을이해하고, 실행할수있다. 시작화면을만드는방법과대체리소스를사용하는방법을이해하고실행할수있다. About 과같은상자를구현하고, 테마를적용하는법을이해하고실행할수있다.

리니어레이아웃 - 2 -

슬라이드 1

헬로, 안드로이드 11 주차 위치파악하기와감지하기 강대기동서대학교컴퓨터정보공학부

01장

슬라이드 1

2 Application Name: Day10_yhg <LinearLayout android:layout_weight="3" > /> an

// 화면을터치하였을때해야할작업구현 case MotionEvent.ACTION_MOVE: // 화면을드래그하였때 // 화면을드래그하였을때해야할작업구현 case MotionEvent.ACTION_UP: // 화면에서터치가사라질때 // 화면에서터치가사라질때해야할자업구현 c

이것은리스트뷰의 setadapter 메소드에잘표현되어있습니다. setadapter 는리스트뷰에사용할데이터객체를넘겨주는메소드입니다. 일반적으로생각한다면 ArrayAdapter 객체를생성하여사용할데이터를저장할것이고데이터가저장된 ArrayAdapter 객체를 setadapt

헬로, 안드로이드 13 주차 SQL 활용하기 (2) 강대기동서대학교컴퓨터정보공학부

sadfasdf

헬로, 안드로이드 7 주차 멀티미디어 강대기동서대학교컴퓨터정보공학부

02 C h a p t e r Java

OpenCV와 함께하는 컴퓨터 비전 프로그래밍 캠프

PowerPoint 프레젠테이션

TipssoftAppActivity.java // 기본소스파일 main.xml // 배치와구성에관련된리소스파일 string.xml // 프로그램에서사용할문자열에관련된리소스파일 컴파일을하고나면 r.java 라는소스파일이하나추가되는데이파일은리소스파일을소스파일에서이용할수있도

adlibr-android_4.x

슬라이드 1

비긴쿡-자바 00앞부속

REMON Android SDK GUIDE (SDK Version 1.4.1) 1 / 25

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

2007백서-001-특집

00목차

¾Ë·¹¸£±âÁöħ¼�1-ÃÖÁ¾

01....b

(291)본문7

PowerPoint 프레젠테이션

학습목표 메뉴를추가하는방법을이해하고실습할수있다. 프로그램의기본설정 (settings) 을정의하는방법을알고실습할수있다. 대화상자를여는방법을알고실습할수있다. 로그메시지로디버깅하는방법을이해한다. 디버거로디버깅하는방법을이해한다.

슬라이드 1

JMF3_심빈구.PDF

뷰그룹 ( 레이아웃 ) 레이아웃이름 ( 클래스이름 ) FrameLayout LinearLayout 설명단일객체를표현하기위한프레임. 왼쪽상단에하나의뷰를배치하기때문에나중 에그린객체만보여준다. 수평또는수직으로자손의뷰를배치. 뷰가들어갈만한공간이없을때는자동으로 스크롤바가나타난다

슬라이드 1

¾Èµå·ÎÀÌµå ³¹Àå-Åë.PDF

안드로이드2_09

ch09

Microsoft PowerPoint - 4주차_Android_UI구현.ppt [호환 모드]

Microsoft Word - 김정훈

콘텐츠 PowerPoint 디자인

자바GUI실전프로그래밍2_장대원.PDF

KARAAUTO_4¿ù.qxd-ÀÌÆå.ps, page Normalize

학습목표 인텐트로다른액티비티나프로그램을실행시킬수있다. 웹뷰를통해웹화면을액티비티화면의일부로구성할수있다. 자바스크립트를통해안드로이드프로그램을호출하는방법을안다. 안드로이드응용프로그램에서웹서비스를이용하는방법을안다.

학습목표 SQLite 가뭔지알고, 이를사용할줄안다. SQL 의기본적인사용법들을안다. SQLite 을이용해기본적인데이터베이스응용프로그램을작성할수있다. 행을추가하는기본적인데이터베이스응용프로그램을작성할수있다. 쿼리를실행하는기본적인데이터베이스응용프로그램을작성할수있다. 쿼리결과

위젯과레이아웃위젯은 View 클래스를상속해화면디스플레이와이벤트처리를할수있도록구현된스크린구성의최소단위를말한다. android.widget 패키지에는여러유형의위젯들이포함되어있다. TextView, ImageView, Button, ImageButton 등은가장간단한위젯들이

Microsoft PowerPoint - 04-UDP Programming.ppt

歯Lecture2.PDF

자바 프로그래밍

Microsoft PowerPoint - 양정수-Android_View_and_Window_System.ppt [호환 모드]

슬라이드 1

Daum 카페

5장.key

INAPP결제 API 가이드

(Microsoft PowerPoint - Ch06.ppt [\310\243\310\257 \270\360\265\345])

12Àå PDF

Spring Boot/JDBC JdbcTemplate/CRUD 예제

12 주차 인텐트

Android Master Key Vulnerability

PowerPoint 프레젠테이션

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

50_1953.pdf

슬라이드 1

Microsoft PowerPoint App Fundamentals[Part2].pptx

PowerPoint Presentation

신림프로그래머_클린코드.key

rmi_박준용_final.PDF

01-OOPConcepts(2).PDF

1. 프로젝트소개 1.1 배경및목적 1.2 시나리오 1.3 프로젝트기능 2. 관련기술 2.1. 안드로이드센서 SENSOR_ORIENTATION ( 방향센서 ) SENSOR_ACCELEROMETER ( 가속도센서 ) 2.2 가속도를이용한거리측정알고리

목차 1. Samsung In-App Purchase 소개 다운로드 IAP 3.0 Helper & Sample IAP 3 제약사항 IAP 3 개발모드 지원상품타입 IAP 3

자바로

untitled

K&R2 Reference Manual 번역본

XML Parser

안드로이드애플리케이션과통합하는데는자바가편하므로대표적인두가지라이브러리를비교해보자. 자바 ID3 태그라이브러리 jaudiotagger ID3v1, ID3v1.1, Lyrics3v1, Mp3, Mp4 (Mp4 오디오, M4a 지원범위 Lyrics3v2, ID3v2.2, ID

초보자를 위한 C# 21일 완성

Spring Data JPA Many To Many 양방향 관계 예제

슬라이드 1

RDS_MAN_NO 도로구간일련번호 NUMBER(12) BSI_INT_SN 기초구간일련번호 NUMBER(10) EQB_MAN_SN 건물군일련번호 NUMBER(10) BULD_SE_CD 건물구분코드 VARCHAR2(1) BULD_MNNM 건물본번 NUMBER(5) BUL

05-class.key

PowerPoint 프레젠테이션

12-file.key

SQLite v 소개 ü SQLite 라이브러리를통해완전한관계형데이터베이스 (RDBMS) 기능제공 ü 오픈소스 ü 표준준수 ü 경량 ü 단일계층 2

제8장 자바 GUI 프로그래밍 II

구글안드로이드프로그래밍액티비티, 인텐트수신자, 그리고서비스 안드로이드애플리케이션의구성요소에는액티비티, 인텐트수신자, 서비스, 컨텐트제공자가있다. 이번호에서는사용자인터페이스를위한액티비티와백그라운드서비스를위한인텐트수신자, 그리고서비스의라이프사이클과활용법에대해살펴보도록하자.

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

JAVA PROGRAMMING 실습 08.다형성

07 자바의 다양한 클래스.key

Contents. 1. PMD ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 2. Metrics ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 3. FindBugs ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 4. ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ

Microsoft PowerPoint - DoItAndroid_PART02_01_기본위젯과레이아웃_Rev.1.0 [호환 모드]

Microsoft PowerPoint - 14주차 강의자료

歯얻는다.PDF

JMF2_심빈구.PDF

학습목표 게임이나프로그램에옵션을추가하는방법을알아본다. 이전의프로그램을계속하기위해상태를저장하는방법을알아본다. 게임에서현재의실행위치를저장하는방법에대해알아본다. 내부의파일시스템을읽고쓰는방법에대해알아본다. SD 카드에접근하는방법에대해알아본다. 여러 UI 위젯들에대해알아본다.

Transcription:

.,,,,,. 11...,,,.,.,.,.

Chapter 14. force feedback.., getsystemservice. String service_name = Context.SENSOR_SERVICE; SensorManager sensormanager = (SensorManager)getSystemService(service_name);. Sensor.,,,. Sensor. Sensor.TYPE_< >.,... Sensor.TYPE_ACCELEROMETER 3. m/s 2..

625 Sensor.TYPE_GYROSCOPE. ( ) Sensor.TYPE_LIGHT. (lux). Sensor.TYPE_MAGNETIC_FIELD ( T). Sensor.TYPE_ORIENTATION. ( ). Sensor.TYPE_PRESSURE. (kpa) Sensor.TYPE_PROXIMITY. (m).,. Sensor.TYPE_TEMPERATURE. ( ),,.., getdefaultsensor.. null. Sensor defaultgyroscope = sensormanager.getdefaultsensor(sensor.type_gyroscope); getsensorlist,..

Chapter 14 List<Sensor> pressuresensors = sensormanager.getsensorlist(sensor.type_pressure); getsensorlist Sensor.TYPE_ALL,. List<Sensor> allsensors = sensormanager.getsensorlist(sensor.type_all);,. 14 1.. SensorEventListener, onsensorchanged, onaccuracychanged. final SensorEventListener mysensoreventlistener = new SensorEventListener() { public void onsensorchanged(sensorevent sensorevent) { // TODO:. ; public void onaccuracychanged(sensor sensor, int accuracy) { // TODO:. onsensorchanged SensorEvent. sensor accuracy. low, medium, high, u reliable.. values ( ) float..

627 timestamp. nanoseconds onaccuracychanged,. accuracy. SensorManager.SENSOR_STATUS_ACCURACY_LOW,. SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM,. SensorManager.SENSOR_STATUS_ACCURACY_HIGH. SensorManager.SENSOR_STATUS_UNRELIABLE..,.,.. Sensor sensor = sensormanager.getdefaultsensor(sensor.type_proximity); sensormanager.registerlistener(mysensoreventlistener, sensor, SensorManager.SENSOR_DELAY_NORMAL);,.. SensorManager.SENSOR_DELAY_FASTEST. SensorManager.SENSOR_DELAY_GAME. SensorManager.SENSOR_DELAY_NORMAL. SensorManager.SENSOR_DELAY_UI UI.

Chapter 14...,.. sensormanager.unregisterlistener(mysensoreventlistener); onresume, onpause. onsensorchanged SensorEvent values. 14 1.,,. http:// developer.android.com/reference/android/hardware/sensorevent.html TYPE_ACCELEROMETER Sensor Manager.GRAVITY_*

629 TYPE_GYROSCOPE TYPE_LIGHT SensorManager.LIGHT_* TYPE_MAGNETIC_FIELD TYPE_ORIENTATION TYPE_PRESSURE TYPE_PROXIMITY TYPE_TEMPERATURE.. Nintendo Wii, AppliPhone, Palm Pre,.,,.,,.

Chapter 14.,. X, Y, Z ( ).,,..,,, augmented reality..,...,, SMS...,. accelerometer. gravitsensor.

631 SensorManager.STANDARD_ GRAVITY,... ( ).,. (X, Lateral), (Y, Longitudinal), (Z, Vertical).. SensorEvent values X Y, Z. 14 1..

Chapter 14.,., X... Y.. Z.,Z 9.8m/s 2.., Sensor.TYPE_ACCELEROMETER SensorEventListener. 12. SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE); int sensortype = Sensor.TYPE_ACCELEROMETER; sm.registerlistener(mysensoreventlistener, sm.getdefaultsensor(sensortype), SensorManager.SENSOR_DELAY_NORMAL);, onsensorchanged. onsensorchanged SensorEvent, float X,,.. final SensorEventListener mysensoreventlistener = new SensorEventListener() { public void onsensorchanged(sensorevent sensorevent) { if (sensorevent.sensor.gettype() == Sensor.TYPE_ACCELEROMETER) { float xaxis_laterala = sensorevent.values[0]; float yaxis_longitudinala = sensorevent.values[1]; float zaxis_verticala = sensorevent.values[2];

633 ; // TODO:.,.. 9.8m/s 2. SensorManager.STANDARD_GRAVITY. 1. Forceometer, Forceometer., main.xml,.. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/acceleration" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textstyle="bold" android:textsize="32sp" android:text="center" android:editable="false" android:singleline="true" android:layout_margin="10px"/> /> <TextView android:id="@+id/maxacceleration" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content"

Chapter 14 android:textstyle="bold" android:textsize="40sp" android:text="center" android:editable="false" android:singleline="true" android:layout_margin="10px"/> /> </LinearLayout> 2. Forceometer TextView SensorManager. SensorManager sensormanager; TextView accelerationtextview; TextView maxaccelerationtextview; float currentacceleration = 0; float maxacceleration = 0; 3. SensorEventListener... private final SensorEventListener sensoreventlistener = new SensorEventListener() { double calibration = SensorManager.STANDARD_GRAVITY; public void onaccuracychanged(sensor sensor, int accuracy) { public void onsensorchanged(sensorevent event) { double x = event.values[0]; double y = event.values[1]; double z = event.values[2]; import import android.hardware.sensormanager; import android.widget.textview; import import android.hardware.sensor; import android.hardware.sensorevent; import android.hardware.sensoreventlistener;

635 double a = Math.round(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2))); currentacceleration = Math.abs((float)(a-calibration)); ; if (currentacceleration > maxacceleration) maxacceleration = currentacceleration; 4. oncreate SensorManager.. @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); accelerationtextview = (TextView)findViewById(R.id.acceleration); maxaccelerationtextview = (TextView)findViewById(R.id.maxAcceleration); sensormanager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensormanager.getdefaultsensor(sensor.type_accelerometer); sensormanager.registerlistener(sensoreventlistener, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); 5.,. updategui. private void updategui() { runonuithread(new Runnable() { public void run() { String currentg = currentacceleration/sensormanager.standard_gravity + "Gs''; accelerationtextview.settext(currentg); import import android.content.context;

Chapter 14 ; ); accelerationtextview.invalidate(); String maxg = maxacceleration/sensormanager.standard_gravity + "Gs''; maxaccelerationtextview.settext(maxg); maxaccelerationtextview.invalidate(); 6., 100ms GUI oncreate. @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); accelerationtextview = (TextView)findViewById(R.id.acceleration); maxaccelerationtextview = (TextView)findViewById(R.id.maxAcceleration); sensormanager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensormanager.getdefaultsensor(sensor.type_accelerometer); sensormanager.registerlistener(sensoreventlistener, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); Timer updatetimer = new Timer("gForceUpdate"); updatetimer.scheduleatfixedrate(new TimerTask() { public void run() { updategui();, 0, 100);. F16,., import import java.util.timer; import java.util.timertask;

637..,. pitch roll..,..,., reference frame.. 14 2 standard reference frame.,.

Chapter 14 ( heading yaw ) X, 0/360 north, 90/360 east, 180/360 south, 270/360 west. Y. 0, ( ) 90, 90, 180/ 180. Z 90 90.0, 90, 90.. 14 3. SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE); int sensortype = Sensor.TYPE_ORIENTATION; sm.registerlistener(myorientationlistener, sm.getdefaultsensor(sensortype), SensorManager.SENSOR_DELAY_NORMAL);, SensorEventListener onsensorchanged. SensorEvent values float values (),,. final SensorEventListener myorientationlistener = new SensorEventListener() { public void onsensorchanged(sensorevent sensorevent) { if (sensorevent.sensor.gettype() == Sensor.TYPE_ORIENTATION) { float headingangle = sensorevent.values[0]; float pitchangle = sensorevent.values[1];

639 float rollangle = sensorevent.values[2]; // TODO:. ; public void onaccuracychanged(sensor sensor, int accuracy) {. orientation reference frame X, Y, Z.. onsensorchanged values. 14 4. float[] accelerometervalues; float[] magneticfieldvalues; final SensorEventListener myaccelerometerlistener = new SensorEventListener() { public void onsensorchanged(sensorevent sensorevent) { if (sensorevent.sensor.gettype() == Sensor.TYPE_ACCELEROMETER) accelerometervalues = sensorevent.values; ; public void onaccuracychanged(sensor sensor, int accuracy) { final SensorEventListener mymagneticfieldlistener = new SensorEventListener() { public void onsensorchanged(sensorevent sensorevent) { if (sensorevent.sensor.gettype() == Sensor.TYPE_MAGNETIC_FIELD) magneticfieldvalues = sensorevent.values; ; public void onaccuracychanged(sensor sensor, int accuracy) {

Chapter 14. UI. SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor asensor = sm.getdefaultsensor(sensor.type_accelerometer); Sensor mfsensor = sm.getdefaultsensor(sensor.type_magnetic_field); sm.registerlistener(myaccelerometerlistener, asensor, SensorManager.SENSOR_DELAY_UI); sm.registerlistener(mymagneticfieldlistener, mfsensor, SensorManager.SENSOR_DELAY_UI);, getrotation Matrix getorientation. getorientation degree radian. float[] values = new float[3]; float[] R = new float[9]; SensorManager.getRotationMatrix(R, null, accelerometervalues, magneticfieldvalues); SensorManager.getOrientation(R, values); //. values[0] = (float) Math.toDegrees(values[0]); values[1] = (float) Math.toDegrees(values[1]); values[2] = (float) Math.toDegrees(values[2]); remapcoordinatesystem,.. remapcoordinatesystem.,.

641 remapcoordinatesystem. getrotationmatrixrotation matrix X Y. X Y. (AXIS_X, AXIS_Y, AXIS_Z, AXIS_MINUS_X, AXIS_MINUS_Y, AXIS_MINUS_Z). 14 5 14 3. SensorManager.getRotationMatrix(R, null, avalues, mvalues); float[] outr = new float[9]; SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_X, SensorManager.AXIS_Z, outr); SensorManager.getOrientation(outR, values); //. values[0] = (float) Math.toDegrees(values[0]); values[1] = (float) Math.toDegrees(values[1]); values[2] = (float) Math.toDegrees(values[2]); 4 CompassView.

Chapter 14,. 1. 4 Compass CompassView Compass. CompassView,. CompassView get/set. float pitch = 0; float roll = 0; public float getpitch() { return pitch; public void setpitch(float pitch) { this.pitch = pitch; public float getroll() { return roll; public void setroll(float roll) { this.roll = roll; 2. ondraw. @Override protected void ondraw(canvas canvas) { [... ondraw... ] 2.1., ( ). int mmeasuredwidth = getmeasuredwidth(); int mmeasuredheight = getmeasuredwidth(); RectF rolloval = new RectF((mMeasuredWidth/3)-mMeasuredWidth/7, (mmeasuredheight/2)-mmeasuredwidth/7,

643 (mmeasuredwidth/3)+mmeasuredwidth/7, (mmeasuredheight/2)+mmeasuredwidth/7 ); markerpaint.setstyle(paint.style.stroke); canvas.drawoval(rolloval, markerpaint); markerpaint.setstyle(paint.style.fill); canvas.save(); canvas.rotate(roll, mmeasuredwidth/3, mmeasuredheight/2); canvas.drawarc(rolloval, 0, 180, false, markerpaint); canvas.restore(); 2.2., forwarangle (). RectF pitchoval = new RectF((2*mMeasuredWidth/3)-mMeasuredWidth/7, (mmeasuredheight/2)-mmeasuredwidth/7, (2*mMeasuredWidth/3)+mMeasuredWidth/7, (mmeasuredheight/2)+mmeasuredwidth/7 ); markerpaint.setstyle(paint.style.stroke); canvas.drawoval(pitchoval, markerpaint); markerpaint.setstyle(paint.style.fill); canvas.drawarc(pitchoval, 0-pitch/2, 180+(pitch), false, markerpaint); markerpaint.setstyle(paint.style.stroke); 3. CompassView., 14 4. 4. Compass.., CompassView SensorManager. import import android.hardware.sensormanager;

Chapter 14 float[] avalues = new float[3]; float[] mvalues = new float[3]; CompassView compassview; SensorManager sensormanager; 5.,, CompassView update Orientation private void updateorientation(float[] values) { if (compassview!= null) { compassview.setbearing(values[0]); compassview.setpitch(values[1]); compassview.setroll(-values[2]); compassview.invalidate(); 6. oncreate CompassView SensorManager,,,. @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); compassview = (CompassView)this.findViewById(R.id.compassView); sensormanager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); updateorientation(new float[] {0, 0, 0); 7. calculateorientation private float[] calculateorientation() { float[] values = new float[3]; float[] R = new float[9]; SensorManager.getRotationMatrix(R, null, avalues, mvalues); import import android.content.context;

645 SensorManager.getOrientation(R, values); //. values[0] = (float) Math.toDegrees(values[0]); values[1] = (float) Math.toDegrees(values[1]); values[2] = (float) Math.toDegrees(values[2]); return values; 8. SensorEventListener. onsensorchanged, calculateorientation updateorientation. private final SensorEventListener sensoreventlistener = new SensorEventListener() { public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == Sensor.TYPE_ACCELEROMETER) avalues = event.values; if (event.sensor.gettype() == Sensor.TYPE_MAGNETIC_FIELD) mvalues = event.values; updateorientation(calculateorientation()); ; public void onaccuracychanged(sensor sensor, int accuracy) { 9. onresume onstop., SensorEventListener. @Override protected void onresume() { super.onresume(); Sensor accelerometer = sensormanager.getdefaultsensor(sensor.type_accelerometer); Sensor magfield = sensormanager.getdefaultsensor(sensor.type_magnetic_field); import import android.hardware.sensor; import android.hardware.sensorevent; import android.hardware.sensoreventlistener;

Chapter 14 sensormanager.registerlistener(sensoreventlistener, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); sensormanager.registerlistener(sensoreventlistener, magfield, SensorManager.SENSOR_DELAY_FASTEST); @Override protected void onstop() { sensormanager.unregisterlistener(sensoreventlistener); super.onstop();,. 10.. calculateorientation. private float[] calculateorientation() { float[] values = new float[3]; float[] R = new float[9]; float[] outr = new float[9]; SensorManager.getRotationMatrix(R, null, avalues, mvalues); SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_X, SensorManager.AXIS_Z, outr); SensorManager.getOrientation(outR, values); //. values[0] = (float) Math.toDegrees(values[0]); values[1] = (float) Math.toDegrees(values[1]); values[2] = (float) Math.toDegrees(values[2]); return values;

647 9 Notifications...,. VIBRATE XML VIBRATE <uses-permission android:name="android.permission.vibrate"/> Vibrator. 14 6 getsystemservice. String vibratorservice = Context.VIBRATOR_SERVICE; Vibrator vibrator = (Vibrator)getSystemService(vibratorService); vibrate. vibrate,.,.. long[] pattern = {1000, 2000, 4000, 8000, 16000 ; vibrator.vibrate(pattern, 0); //. vibrator.vibrate(1000); // 1. cancel..

Chapter 14.,.,,,...., AIDL Wake L cks. TTS,.,.