SlideShare a Scribd company logo
1 of 15
1.  안드로이드 추가 하드웨어  API 안드로이드 기기가 제공하는 저수준 하드웨어 기능에 접근하기 위해 다양한  API 가 사용된다 . 안드로이드 기기에 장착 될수 있는 장치로는  WIFI,  방향계 ,  나침반들이 있고 ,  이는 가속계 ( 속력을 감지 ),  나침반  ( 방향을 감지 ) 의 용도로 쓰일수 있으며 우리는 이러한 장치를 사용할 수 있는 클래스 및 메써드를 다양하게 사용할 것이다 . 단 ,  에뮬레이터는 완전한 기기가 아니므로 실습의 성공여부를 확인 할수 없고 ,  메써드를 보고 한번 코딩해보는 것에 목적을 두겠다 .
2.  장치 감지기 사용하기 응용프로그램은 유요한 센서매니저 인스턴스를 이용하여 감지기의 자료를 받아 볼 수 있다 . 이것은 서비스 시스템 !!  따라서  getSystemService 메서드로 얻는다 .
3.  식별자 SensorManager  클래스에는 기기에 장착되어 있는 여러 감지기에 대한 식별자들을 정의한다 따라서 우리는 그 식별자를 구분하고 그 식별자에 따른 메서드를 사용한다 . 따라서 그 식별자들을 우리 프로그램 내에서 쓸수 있도록  id 를 다르게 정하여 기록하여야 한다 . ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
4.  감지기들의 측정 판독 감지기들의 측정을 판독 하라면  SensorListener 의 주요 메서드를 구현해야 한다 . 반드시 구현해야 하는 메서드로는  onAccuracychanged()  와  onSensorChanged() 가 있다 .
5.  감지기들의 측정판독  2 첫인수는 감지기의 식별자이며 , 두번째 인수는 감지기의 측정자료이다 .(ex  온도 ,  거리 ,  속도 )
6.  감지기의 측정치 감지기의 측정치가 갱신 되었을 때 ,  메서드를 다시 호출 하려면 ,  다음과같이  SensorListener 에 구현을 등록해야 합니다 .
7.  장치 감지기 사용하기 코드 1- sensors.XML <?xml version= &quot;1.0&quot; encoding=&quot;utf-8&quot;?> <RelativeLayout xmlns:android= &quot;http://schemas.android.com/apk/res/android&quot; android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot;> <ScrollView android:layout_width= &quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;> <LinearLayout android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot; > <TextView android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Sensors Info&quot; /> <RadioGroup android:id= &quot;@+id/sensor_group&quot; android:layout_height= &quot;wrap_content&quot; android:layout_width= &quot;wrap_content&quot; > <RadioButton android:id= &quot;@+id/sensor_accel&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 가속기 &quot; /> <RadioButton android:id= &quot;@+id/sensor_temp&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 온도계 &quot; /> <RadioButton android:id= &quot;@+id/sensor_light&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 조명계 &quot; android:layout_width= &quot;wrap_content&quot; /> <RadioButton android:id= &quot;@+id/sensor_mag&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 나침반 &quot; /> <RadioButton android:id= &quot;@+id/sensor_orient&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 방향계 &quot; /> <RadioButton android:id= &quot;@+id/sensor_prox&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 거리계 &quot; /> </RadioGroup> <LinearLayout android:orientation= &quot;horizontal&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot;> <Button android:id= &quot;@+id/start_sensor&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Start Sensor&quot; /> <Button android:id= &quot;@+id/stop_sensor&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Stop Sensor&quot; android:visibility= &quot;gone&quot; /> </LinearLayout> </LinearLayout> </ScrollView> <LinearLayout android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:layout_alignParentBottom= &quot;true&quot;> <TextView android:id= &quot;@+id/status&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;... data will go here ...&quot;  android:layout_gravity= &quot;right&quot; android:gravity=&quot;right&quot;/> </LinearLayout> </RelativeLayout>
8.  장치 감지기 사용하기 코드 2-  자바코드
9.  배터리 잔량과 외부 전원 정보 모바일 기기들은 배터리를 전원으로 작동한다 .  모든 응용프로그램들이 배터리의 정보를 알필요는 없으나 ,  요즘 응용프로그램들은 배터리의 전원 여부를 파악하여 현 프로그램이 작동방식에 영향을 주게 만들고 있다 .  고로 우리의 응용프로그램도 이를 이용할수 있게 하기 위하여  이 장을 준비 했다 . 응용 프로그램에서 배터리 상태 정보에 접근을 하기 위하여 ,  특수한 권한이 필요한데 , android.Manifast.xml  에 다음과 같은 요소를 추가한다 .
10.  배터리 잔량과 외부 전원 정보 배터리로 부터 여러가지 정보를 받아서 다양한 필드들의 수치를 뽑아 낸다 . 각 필드들은 현 배터리의 절대적인 수치가 아닌 사용자들에게 필요한 상대적인수치이다 . 이 수치들에 대한 설명은  p450 에 나와있고 , 이 수치에 대한 데이터를 받는 것은 ,  코드를 보면서 알아 보도록 한다 .
11.  배터리 잔량과 외부 전원 정보 각각의 배터리에 대한 수치들은  BroadcastReceiver 객체의  onReceive 함수를 통해 받아 올수 있다 . 잘린 부분은 그 상태를 표시하기 위한 스트링이다 . Intent  객체를 이용 각각의 상대적인 수치를 지정 .  그리고 받아와서 출력할수 있는 스트링을 만들수 있다 . 각각의 수치에 대한 설명은  p450 에 있다 .
12.  배터리 정보의 각각의 필드 감지기의 식별자 처럼 각각의 필드에 있는 수치에 대한 식별자도 정의하여 입력해야 우리가 원하는 정보를 찾아서 쓸 수 있다 .
13.  배터리 잔량과 외부 전원 정보 - Battery.xml <?xml version= &quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android= &quot;http://schemas.android.com/apk/res/android&quot; android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot;> <TextView android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Battery Info&quot; /> <LinearLayout android:orientation= &quot;horizontal&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot;> <Button android:id= &quot;@+id/start&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Start&quot; /> <Button android:id= &quot;@+id/stop&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Stop&quot; android:visibility= &quot;gone&quot; /> </LinearLayout> <TextView android:id= &quot;@+id/status&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;... data will go here ...&quot; /> <ImageView android:id= &quot;@+id/icon&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot;></ImageView> </LinearLayout>
14.  배터리 잔량과 외부 전원 정보 -  자바코드 package A5.com; import android.app.Activity; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.BatteryManager; import  android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class com extends Activity { private BroadcastReceiver batteryRcv = null; private static final Map<Integer, String>  healthValueMap = new  HashMap<Integer, String>() { { put(BatteryManager. BATTERY_HEALTH_DEAD, &quot;Dead&quot;); put(BatteryManager. BATTERY_HEALTH_GOOD, &quot;Good&quot;); put(BatteryManager. BATTERY_HEALTH_OVER_VOLTAGE, &quot;Over voltage&quot;); put(BatteryManager. BATTERY_HEALTH_OVERHEAT, &quot;Over heating&quot;); put(BatteryManager. BATTERY_HEALTH_UNKNOWN, &quot;Unknown&quot;); put(BatteryManager. BATTERY_HEALTH_UNSPECIFIED_FAILURE, &quot;Failure, but unknown&quot;); put(-1, &quot;Not Reported&quot;); } }; private static final Map<Integer, String>  statusValueMap = new  HashMap<Integer, String>() { { put(BatteryManager. BATTERY_STATUS_CHARGING, &quot;Charging&quot;); put(BatteryManager. BATTERY_STATUS_DISCHARGING, &quot;Discharging&quot;); put(BatteryManager. BATTERY_STATUS_FULL, &quot;Full&quot;); put(BatteryManager. BATTERY_STATUS_NOT_CHARGING, &quot;Not Charging&quot;); put(BatteryManager. BATTERY_STATUS_UNKNOWN, &quot;Unknown&quot;); put(-1, &quot;Not Reported&quot;); } }; private static final Map<Integer, String>  pluggedValueMap = new  HashMap<Integer, String>() { { put(BatteryManager. BATTERY_PLUGGED_AC, &quot;On AC&quot;); put(BatteryManager. BATTERY_PLUGGED_USB, &quot;On USB&quot;); put(-1, &quot;Not Reported&quot;); } }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. battery); final ImageView icon = (ImageView) findViewById(R.id. icon); final Button start = (Button) findViewById(R.id. start); final Button stop = (Button) findViewById(R.id. stop); final TextView status = (TextView) findViewById(R.id. status); batteryRcv =  new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(&quot;level&quot;, -1); int maxValue = intent.getIntExtra(&quot;scale&quot;, -1); int batteryStatus = intent.getIntExtra(&quot;status&quot;, -1); int batteryHealth = intent.getIntExtra(&quot;health&quot;, -1); int batteryPlugged = intent.getIntExtra(&quot;plugged&quot;, -1); String batteryTech = intent.getStringExtra(&quot;technology&quot;); int batteryIcon = intent.getIntExtra(&quot;icon-small&quot;, -1); float batteryVoltage = (float) intent.getIntExtra(&quot;voltage&quot;, -1) / 1000; boolean battery = intent.getBooleanExtra(&quot;present&quot;, false); float batteryTemp = (float) intent.getIntExtra(&quot;temperature&quot;, -1) / 10; /* used to determine keys and types * Bundle extras = intent.getExtras(); Set<String> keys = * extras.keySet(); Iterator<String> allKeys = keys.iterator(); * while (allKeys.hasNext()) { String key = allKeys.next(); * Log.v(&quot;Battery&quot;, key); } */ int chargedPct = (level * 100) / maxValue; String batteryInfo = &quot;Battery Info:Health=&quot; +  healthValueMap.get(batteryHealth) + &quot;&quot; + &quot;Status=&quot; + statusValueMap.get(batteryStatus) + &quot;&quot; + &quot;Charged % = &quot; + chargedPct + &quot;%&quot; + &quot;Plugged = &quot; +  pluggedValueMap.get(batteryPlugged) + &quot;&quot; + &quot;Type = &quot; + batteryTech + &quot;&quot; + &quot;Voltage = &quot; + batteryVoltage + &quot; volts&quot; + &quot;Temperature = &quot; + batteryTemp + &quot; 좧 &quot; + &quot;Battery present = &quot; + battery + &quot;&quot;; status.setText(batteryInfo); icon.setImageResource(batteryIcon); Toast. makeText(com. this, &quot;Battery state changed&quot;, Toast.LENGTH_LONG).show(); } }; start.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { registerReceiver(batteryRcv,  new IntentFilter(Intent. ACTION_BATTERY_CHANGED)); Toast. makeText(com. this, &quot;Battery monitoring started&quot;, Toast.LENGTH_SHORT).show(); start.setVisibility(View. GONE); stop.setVisibility(View. VISIBLE); } }); stop.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { unregisterReceiver(batteryRcv); Toast. makeText(com. this, &quot;Battery monitoring stopped&quot;, Toast.LENGTH_SHORT).show(); stop.setVisibility(View. GONE); start.setVisibility(View. VISIBLE); } }); } @Override protected void onPause() { if (batteryRcv != null) { unregisterReceiver(batteryRcv); batteryRcv =  null; } super.onPause(); } }
15.  후기 . 본 응용프로그램의 버튼이나 텍스트뷰등의 구현은 이미 배운것이므로  설명하지 않았습니다 . 이제우리도  intent 를 사용하여 페이지를 넘긴다든가 ,  텍스트뷰를 조정하는것 ,  그리고 버튼 및 메뉴 활용의 빈도를 높여 프로젝트를 진행할수 있었으면 좋겠습니다 . 시간이 얼마 남지 않았고 ,  앞으로 매우 바쁜 나날을 보내 겠지만 조금만더 힘을내서 프로젝트를 성공적으로 완성 시켰으면 좋겠습니다 . A5  파이팅 !! 중요한건 .. PDF  파일 연동인데 ㅠ 최선을 다하도록 하겟슴돠 <~!~!~

More Related Content

Viewers also liked

Toi theo-dao-chua, lm. doan quang, cmc
Toi theo-dao-chua, lm. doan quang, cmcToi theo-dao-chua, lm. doan quang, cmc
Toi theo-dao-chua, lm. doan quang, cmcThịnh Vũ
 
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!oxfordcollegelibrary
 
Pictures of students in sw 475
Pictures of students in sw 475Pictures of students in sw 475
Pictures of students in sw 475pegart
 
Releituras Romero Britto
Releituras Romero BrittoReleituras Romero Britto
Releituras Romero Brittodalvanice
 
Firmalar için mobil eğitim
Firmalar için mobil eğitimFirmalar için mobil eğitim
Firmalar için mobil eğitimtaylanozkok
 
Press release world memory championship 2013
Press release world memory championship 2013Press release world memory championship 2013
Press release world memory championship 2013Yudi Lesmana
 
Семинар Модели автоматизации и оптимизации бизнеса
Семинар Модели автоматизации и оптимизации бизнесаСеминар Модели автоматизации и оптимизации бизнеса
Семинар Модели автоматизации и оптимизации бизнесаАльберт Коррч
 
Shot count/ description.
Shot count/ description.Shot count/ description.
Shot count/ description.afrostwick
 
Rapid web development, the right way.
Rapid web development, the right way.Rapid web development, the right way.
Rapid web development, the right way.nubela
 
Cyberguys, inc. coupon
Cyberguys, inc. couponCyberguys, inc. coupon
Cyberguys, inc. couponMaterazzi3
 
Система управления личными финансами
Система управления личными финансамиСистема управления личными финансами
Система управления личными финансамиАльберт Коррч
 

Viewers also liked (17)

Toi theo-dao-chua, lm. doan quang, cmc
Toi theo-dao-chua, lm. doan quang, cmcToi theo-dao-chua, lm. doan quang, cmc
Toi theo-dao-chua, lm. doan quang, cmc
 
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!
Mary Moser: LOLcats, Celebrities, and (Red Panda) Bears -- Oh, My!!
 
Artsmart2
Artsmart2Artsmart2
Artsmart2
 
Louise Cohen | PROJECTS
Louise Cohen | PROJECTSLouise Cohen | PROJECTS
Louise Cohen | PROJECTS
 
Economy katalog
Economy katalogEconomy katalog
Economy katalog
 
Pictures of students in sw 475
Pictures of students in sw 475Pictures of students in sw 475
Pictures of students in sw 475
 
Terrestrial Support of Aquatic Food Webs
Terrestrial Support of Aquatic Food WebsTerrestrial Support of Aquatic Food Webs
Terrestrial Support of Aquatic Food Webs
 
WRIT 2131
WRIT 2131  WRIT 2131
WRIT 2131
 
Ussba cat
Ussba catUssba cat
Ussba cat
 
Releituras Romero Britto
Releituras Romero BrittoReleituras Romero Britto
Releituras Romero Britto
 
Firmalar için mobil eğitim
Firmalar için mobil eğitimFirmalar için mobil eğitim
Firmalar için mobil eğitim
 
Press release world memory championship 2013
Press release world memory championship 2013Press release world memory championship 2013
Press release world memory championship 2013
 
Семинар Модели автоматизации и оптимизации бизнеса
Семинар Модели автоматизации и оптимизации бизнесаСеминар Модели автоматизации и оптимизации бизнеса
Семинар Модели автоматизации и оптимизации бизнеса
 
Shot count/ description.
Shot count/ description.Shot count/ description.
Shot count/ description.
 
Rapid web development, the right way.
Rapid web development, the right way.Rapid web development, the right way.
Rapid web development, the right way.
 
Cyberguys, inc. coupon
Cyberguys, inc. couponCyberguys, inc. coupon
Cyberguys, inc. coupon
 
Система управления личными финансами
Система управления личными финансамиСистема управления личными финансами
Система управления личными финансами
 

Similar to 안드로이드스터디 14

Open source APM Scouter로 모니터링 잘 하기
Open source APM Scouter로 모니터링 잘 하기Open source APM Scouter로 모니터링 잘 하기
Open source APM Scouter로 모니터링 잘 하기GunHee Lee
 
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장Cyworld AppStore (SK Communications)
 
Angular 2 rc5 조사
Angular 2 rc5 조사Angular 2 rc5 조사
Angular 2 rc5 조사Rjs Ryu
 
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발LGU+
 
[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발NAVER D2
 
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디Youngbin Han
 
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본Lee Sang-Ho
 
Scouter Tutorial & Sprint
Scouter Tutorial & SprintScouter Tutorial & Sprint
Scouter Tutorial & SprintGunHee Lee
 
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)Sang Don Kim
 
RIA Description Language(09.11.04)
RIA Description Language(09.11.04)RIA Description Language(09.11.04)
RIA Description Language(09.11.04)Ethan Cha
 
[213]monitoringwithscouter 이건희
[213]monitoringwithscouter 이건희[213]monitoringwithscouter 이건희
[213]monitoringwithscouter 이건희NAVER D2
 
21 application and_network_status
21 application and_network_status21 application and_network_status
21 application and_network_status운용 최
 
Google awareness api 활용 및 테스트
Google awareness api 활용 및 테스트Google awareness api 활용 및 테스트
Google awareness api 활용 및 테스트선경 김선경
 
HD 애플리케이션 만들기(파이어몽키 활용)
HD 애플리케이션 만들기(파이어몽키 활용)HD 애플리케이션 만들기(파이어몽키 활용)
HD 애플리케이션 만들기(파이어몽키 활용)Devgear
 

Similar to 안드로이드스터디 14 (20)

Jqm+appspresso
Jqm+appspressoJqm+appspresso
Jqm+appspresso
 
Open source APM Scouter로 모니터링 잘 하기
Open source APM Scouter로 모니터링 잘 하기Open source APM Scouter로 모니터링 잘 하기
Open source APM Scouter로 모니터링 잘 하기
 
Ionic project guide
Ionic project guideIonic project guide
Ionic project guide
 
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장
008. 싸이월드 앱스토어 api 소개 및 활용법 안내 sk컴즈 장원익 과장
 
Angular 2 rc5 조사
Angular 2 rc5 조사Angular 2 rc5 조사
Angular 2 rc5 조사
 
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 
Designing Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom TabletDesigning Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom Tablet
 
Moving cleaner
Moving cleanerMoving cleaner
Moving cleaner
 
[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발
 
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
2.Connect Sunshine to the Cloud - 시온고 안드로이드 스터디
 
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본
[방송통신대 컴퓨터과학과] 2020년 1학기 전공 모바일 앱 프로그래밍 기말평가 제출본
 
Scouter Tutorial & Sprint
Scouter Tutorial & SprintScouter Tutorial & Sprint
Scouter Tutorial & Sprint
 
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)
[Td 2015]알아두면 핵 이득! vc++로 안드로이드 개발하기(김성엽)
 
RIA Description Language(09.11.04)
RIA Description Language(09.11.04)RIA Description Language(09.11.04)
RIA Description Language(09.11.04)
 
[213]monitoringwithscouter 이건희
[213]monitoringwithscouter 이건희[213]monitoringwithscouter 이건희
[213]monitoringwithscouter 이건희
 
21 application and_network_status
21 application and_network_status21 application and_network_status
21 application and_network_status
 
Google awareness api 활용 및 테스트
Google awareness api 활용 및 테스트Google awareness api 활용 및 테스트
Google awareness api 활용 및 테스트
 
HD 애플리케이션 만들기(파이어몽키 활용)
HD 애플리케이션 만들기(파이어몽키 활용)HD 애플리케이션 만들기(파이어몽키 활용)
HD 애플리케이션 만들기(파이어몽키 활용)
 
4조 졸업작품
4조 졸업작품4조 졸업작품
4조 졸업작품
 
증강현실 기술 및 응용 사례 분석
증강현실 기술 및 응용 사례 분석증강현실 기술 및 응용 사례 분석
증강현실 기술 및 응용 사례 분석
 

More from jangpd007

자바스터디 4
자바스터디 4자바스터디 4
자바스터디 4jangpd007
 
자바스터디 3 3
자바스터디 3 3자바스터디 3 3
자바스터디 3 3jangpd007
 
자바스터디 3 2
자바스터디 3 2자바스터디 3 2
자바스터디 3 2jangpd007
 
자바스터디 3 1
자바스터디 3 1자바스터디 3 1
자바스터디 3 1jangpd007
 
자바스터디 2
자바스터디 2자바스터디 2
자바스터디 2jangpd007
 
자바스터디 1
자바스터디 1자바스터디 1
자바스터디 1jangpd007
 
안드로이드스터디 13
안드로이드스터디 13안드로이드스터디 13
안드로이드스터디 13jangpd007
 
안드로이드스터디 12
안드로이드스터디 12안드로이드스터디 12
안드로이드스터디 12jangpd007
 
안드로이드스터디 11
안드로이드스터디 11안드로이드스터디 11
안드로이드스터디 11jangpd007
 
안드로이드스터디 10
안드로이드스터디 10안드로이드스터디 10
안드로이드스터디 10jangpd007
 
안드로이드스터디 9
안드로이드스터디 9안드로이드스터디 9
안드로이드스터디 9jangpd007
 
안드로이드스터디 8
안드로이드스터디 8안드로이드스터디 8
안드로이드스터디 8jangpd007
 
안드로이드스터디 7
안드로이드스터디 7안드로이드스터디 7
안드로이드스터디 7jangpd007
 
안드로이드스터디 6
안드로이드스터디 6안드로이드스터디 6
안드로이드스터디 6jangpd007
 
안드로이드스터디 5
안드로이드스터디 5안드로이드스터디 5
안드로이드스터디 5jangpd007
 
안드로이드스터디 4
안드로이드스터디 4안드로이드스터디 4
안드로이드스터디 4jangpd007
 
안드로이드스터디 3
안드로이드스터디 3안드로이드스터디 3
안드로이드스터디 3jangpd007
 
안드로이드스터디 2
안드로이드스터디 2안드로이드스터디 2
안드로이드스터디 2jangpd007
 
안드로이드스터디 1
안드로이드스터디 1안드로이드스터디 1
안드로이드스터디 1jangpd007
 

More from jangpd007 (19)

자바스터디 4
자바스터디 4자바스터디 4
자바스터디 4
 
자바스터디 3 3
자바스터디 3 3자바스터디 3 3
자바스터디 3 3
 
자바스터디 3 2
자바스터디 3 2자바스터디 3 2
자바스터디 3 2
 
자바스터디 3 1
자바스터디 3 1자바스터디 3 1
자바스터디 3 1
 
자바스터디 2
자바스터디 2자바스터디 2
자바스터디 2
 
자바스터디 1
자바스터디 1자바스터디 1
자바스터디 1
 
안드로이드스터디 13
안드로이드스터디 13안드로이드스터디 13
안드로이드스터디 13
 
안드로이드스터디 12
안드로이드스터디 12안드로이드스터디 12
안드로이드스터디 12
 
안드로이드스터디 11
안드로이드스터디 11안드로이드스터디 11
안드로이드스터디 11
 
안드로이드스터디 10
안드로이드스터디 10안드로이드스터디 10
안드로이드스터디 10
 
안드로이드스터디 9
안드로이드스터디 9안드로이드스터디 9
안드로이드스터디 9
 
안드로이드스터디 8
안드로이드스터디 8안드로이드스터디 8
안드로이드스터디 8
 
안드로이드스터디 7
안드로이드스터디 7안드로이드스터디 7
안드로이드스터디 7
 
안드로이드스터디 6
안드로이드스터디 6안드로이드스터디 6
안드로이드스터디 6
 
안드로이드스터디 5
안드로이드스터디 5안드로이드스터디 5
안드로이드스터디 5
 
안드로이드스터디 4
안드로이드스터디 4안드로이드스터디 4
안드로이드스터디 4
 
안드로이드스터디 3
안드로이드스터디 3안드로이드스터디 3
안드로이드스터디 3
 
안드로이드스터디 2
안드로이드스터디 2안드로이드스터디 2
안드로이드스터디 2
 
안드로이드스터디 1
안드로이드스터디 1안드로이드스터디 1
안드로이드스터디 1
 

안드로이드스터디 14

  • 1. 1. 안드로이드 추가 하드웨어 API 안드로이드 기기가 제공하는 저수준 하드웨어 기능에 접근하기 위해 다양한 API 가 사용된다 . 안드로이드 기기에 장착 될수 있는 장치로는 WIFI, 방향계 , 나침반들이 있고 , 이는 가속계 ( 속력을 감지 ), 나침반 ( 방향을 감지 ) 의 용도로 쓰일수 있으며 우리는 이러한 장치를 사용할 수 있는 클래스 및 메써드를 다양하게 사용할 것이다 . 단 , 에뮬레이터는 완전한 기기가 아니므로 실습의 성공여부를 확인 할수 없고 , 메써드를 보고 한번 코딩해보는 것에 목적을 두겠다 .
  • 2. 2. 장치 감지기 사용하기 응용프로그램은 유요한 센서매니저 인스턴스를 이용하여 감지기의 자료를 받아 볼 수 있다 . 이것은 서비스 시스템 !! 따라서 getSystemService 메서드로 얻는다 .
  • 3.
  • 4. 4. 감지기들의 측정 판독 감지기들의 측정을 판독 하라면 SensorListener 의 주요 메서드를 구현해야 한다 . 반드시 구현해야 하는 메서드로는 onAccuracychanged() 와 onSensorChanged() 가 있다 .
  • 5. 5. 감지기들의 측정판독 2 첫인수는 감지기의 식별자이며 , 두번째 인수는 감지기의 측정자료이다 .(ex 온도 , 거리 , 속도 )
  • 6. 6. 감지기의 측정치 감지기의 측정치가 갱신 되었을 때 , 메서드를 다시 호출 하려면 , 다음과같이 SensorListener 에 구현을 등록해야 합니다 .
  • 7. 7. 장치 감지기 사용하기 코드 1- sensors.XML <?xml version= &quot;1.0&quot; encoding=&quot;utf-8&quot;?> <RelativeLayout xmlns:android= &quot;http://schemas.android.com/apk/res/android&quot; android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot;> <ScrollView android:layout_width= &quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot;> <LinearLayout android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot; > <TextView android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Sensors Info&quot; /> <RadioGroup android:id= &quot;@+id/sensor_group&quot; android:layout_height= &quot;wrap_content&quot; android:layout_width= &quot;wrap_content&quot; > <RadioButton android:id= &quot;@+id/sensor_accel&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 가속기 &quot; /> <RadioButton android:id= &quot;@+id/sensor_temp&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 온도계 &quot; /> <RadioButton android:id= &quot;@+id/sensor_light&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 조명계 &quot; android:layout_width= &quot;wrap_content&quot; /> <RadioButton android:id= &quot;@+id/sensor_mag&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 나침반 &quot; /> <RadioButton android:id= &quot;@+id/sensor_orient&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 방향계 &quot; /> <RadioButton android:id= &quot;@+id/sensor_prox&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot; 거리계 &quot; /> </RadioGroup> <LinearLayout android:orientation= &quot;horizontal&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot;> <Button android:id= &quot;@+id/start_sensor&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Start Sensor&quot; /> <Button android:id= &quot;@+id/stop_sensor&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Stop Sensor&quot; android:visibility= &quot;gone&quot; /> </LinearLayout> </LinearLayout> </ScrollView> <LinearLayout android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:layout_alignParentBottom= &quot;true&quot;> <TextView android:id= &quot;@+id/status&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;... data will go here ...&quot; android:layout_gravity= &quot;right&quot; android:gravity=&quot;right&quot;/> </LinearLayout> </RelativeLayout>
  • 8. 8. 장치 감지기 사용하기 코드 2- 자바코드
  • 9. 9. 배터리 잔량과 외부 전원 정보 모바일 기기들은 배터리를 전원으로 작동한다 . 모든 응용프로그램들이 배터리의 정보를 알필요는 없으나 , 요즘 응용프로그램들은 배터리의 전원 여부를 파악하여 현 프로그램이 작동방식에 영향을 주게 만들고 있다 . 고로 우리의 응용프로그램도 이를 이용할수 있게 하기 위하여 이 장을 준비 했다 . 응용 프로그램에서 배터리 상태 정보에 접근을 하기 위하여 , 특수한 권한이 필요한데 , android.Manifast.xml 에 다음과 같은 요소를 추가한다 .
  • 10. 10. 배터리 잔량과 외부 전원 정보 배터리로 부터 여러가지 정보를 받아서 다양한 필드들의 수치를 뽑아 낸다 . 각 필드들은 현 배터리의 절대적인 수치가 아닌 사용자들에게 필요한 상대적인수치이다 . 이 수치들에 대한 설명은 p450 에 나와있고 , 이 수치에 대한 데이터를 받는 것은 , 코드를 보면서 알아 보도록 한다 .
  • 11. 11. 배터리 잔량과 외부 전원 정보 각각의 배터리에 대한 수치들은 BroadcastReceiver 객체의 onReceive 함수를 통해 받아 올수 있다 . 잘린 부분은 그 상태를 표시하기 위한 스트링이다 . Intent 객체를 이용 각각의 상대적인 수치를 지정 . 그리고 받아와서 출력할수 있는 스트링을 만들수 있다 . 각각의 수치에 대한 설명은 p450 에 있다 .
  • 12. 12. 배터리 정보의 각각의 필드 감지기의 식별자 처럼 각각의 필드에 있는 수치에 대한 식별자도 정의하여 입력해야 우리가 원하는 정보를 찾아서 쓸 수 있다 .
  • 13. 13. 배터리 잔량과 외부 전원 정보 - Battery.xml <?xml version= &quot;1.0&quot; encoding=&quot;utf-8&quot;?> <LinearLayout xmlns:android= &quot;http://schemas.android.com/apk/res/android&quot; android:orientation= &quot;vertical&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;fill_parent&quot;> <TextView android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Battery Info&quot; /> <LinearLayout android:orientation= &quot;horizontal&quot; android:layout_width= &quot;fill_parent&quot; android:layout_height= &quot;wrap_content&quot;> <Button android:id= &quot;@+id/start&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Start&quot; /> <Button android:id= &quot;@+id/stop&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;Stop&quot; android:visibility= &quot;gone&quot; /> </LinearLayout> <TextView android:id= &quot;@+id/status&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot; android:text= &quot;... data will go here ...&quot; /> <ImageView android:id= &quot;@+id/icon&quot; android:layout_width= &quot;wrap_content&quot; android:layout_height= &quot;wrap_content&quot;></ImageView> </LinearLayout>
  • 14. 14. 배터리 잔량과 외부 전원 정보 - 자바코드 package A5.com; import android.app.Activity; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.BatteryManager; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class com extends Activity { private BroadcastReceiver batteryRcv = null; private static final Map<Integer, String> healthValueMap = new HashMap<Integer, String>() { { put(BatteryManager. BATTERY_HEALTH_DEAD, &quot;Dead&quot;); put(BatteryManager. BATTERY_HEALTH_GOOD, &quot;Good&quot;); put(BatteryManager. BATTERY_HEALTH_OVER_VOLTAGE, &quot;Over voltage&quot;); put(BatteryManager. BATTERY_HEALTH_OVERHEAT, &quot;Over heating&quot;); put(BatteryManager. BATTERY_HEALTH_UNKNOWN, &quot;Unknown&quot;); put(BatteryManager. BATTERY_HEALTH_UNSPECIFIED_FAILURE, &quot;Failure, but unknown&quot;); put(-1, &quot;Not Reported&quot;); } }; private static final Map<Integer, String> statusValueMap = new HashMap<Integer, String>() { { put(BatteryManager. BATTERY_STATUS_CHARGING, &quot;Charging&quot;); put(BatteryManager. BATTERY_STATUS_DISCHARGING, &quot;Discharging&quot;); put(BatteryManager. BATTERY_STATUS_FULL, &quot;Full&quot;); put(BatteryManager. BATTERY_STATUS_NOT_CHARGING, &quot;Not Charging&quot;); put(BatteryManager. BATTERY_STATUS_UNKNOWN, &quot;Unknown&quot;); put(-1, &quot;Not Reported&quot;); } }; private static final Map<Integer, String> pluggedValueMap = new HashMap<Integer, String>() { { put(BatteryManager. BATTERY_PLUGGED_AC, &quot;On AC&quot;); put(BatteryManager. BATTERY_PLUGGED_USB, &quot;On USB&quot;); put(-1, &quot;Not Reported&quot;); } }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. battery); final ImageView icon = (ImageView) findViewById(R.id. icon); final Button start = (Button) findViewById(R.id. start); final Button stop = (Button) findViewById(R.id. stop); final TextView status = (TextView) findViewById(R.id. status); batteryRcv = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(&quot;level&quot;, -1); int maxValue = intent.getIntExtra(&quot;scale&quot;, -1); int batteryStatus = intent.getIntExtra(&quot;status&quot;, -1); int batteryHealth = intent.getIntExtra(&quot;health&quot;, -1); int batteryPlugged = intent.getIntExtra(&quot;plugged&quot;, -1); String batteryTech = intent.getStringExtra(&quot;technology&quot;); int batteryIcon = intent.getIntExtra(&quot;icon-small&quot;, -1); float batteryVoltage = (float) intent.getIntExtra(&quot;voltage&quot;, -1) / 1000; boolean battery = intent.getBooleanExtra(&quot;present&quot;, false); float batteryTemp = (float) intent.getIntExtra(&quot;temperature&quot;, -1) / 10; /* used to determine keys and types * Bundle extras = intent.getExtras(); Set<String> keys = * extras.keySet(); Iterator<String> allKeys = keys.iterator(); * while (allKeys.hasNext()) { String key = allKeys.next(); * Log.v(&quot;Battery&quot;, key); } */ int chargedPct = (level * 100) / maxValue; String batteryInfo = &quot;Battery Info:Health=&quot; + healthValueMap.get(batteryHealth) + &quot;&quot; + &quot;Status=&quot; + statusValueMap.get(batteryStatus) + &quot;&quot; + &quot;Charged % = &quot; + chargedPct + &quot;%&quot; + &quot;Plugged = &quot; + pluggedValueMap.get(batteryPlugged) + &quot;&quot; + &quot;Type = &quot; + batteryTech + &quot;&quot; + &quot;Voltage = &quot; + batteryVoltage + &quot; volts&quot; + &quot;Temperature = &quot; + batteryTemp + &quot; 좧 &quot; + &quot;Battery present = &quot; + battery + &quot;&quot;; status.setText(batteryInfo); icon.setImageResource(batteryIcon); Toast. makeText(com. this, &quot;Battery state changed&quot;, Toast.LENGTH_LONG).show(); } }; start.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { registerReceiver(batteryRcv, new IntentFilter(Intent. ACTION_BATTERY_CHANGED)); Toast. makeText(com. this, &quot;Battery monitoring started&quot;, Toast.LENGTH_SHORT).show(); start.setVisibility(View. GONE); stop.setVisibility(View. VISIBLE); } }); stop.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { unregisterReceiver(batteryRcv); Toast. makeText(com. this, &quot;Battery monitoring stopped&quot;, Toast.LENGTH_SHORT).show(); stop.setVisibility(View. GONE); start.setVisibility(View. VISIBLE); } }); } @Override protected void onPause() { if (batteryRcv != null) { unregisterReceiver(batteryRcv); batteryRcv = null; } super.onPause(); } }
  • 15. 15. 후기 . 본 응용프로그램의 버튼이나 텍스트뷰등의 구현은 이미 배운것이므로 설명하지 않았습니다 . 이제우리도 intent 를 사용하여 페이지를 넘긴다든가 , 텍스트뷰를 조정하는것 , 그리고 버튼 및 메뉴 활용의 빈도를 높여 프로젝트를 진행할수 있었으면 좋겠습니다 . 시간이 얼마 남지 않았고 , 앞으로 매우 바쁜 나날을 보내 겠지만 조금만더 힘을내서 프로젝트를 성공적으로 완성 시켰으면 좋겠습니다 . A5 파이팅 !! 중요한건 .. PDF 파일 연동인데 ㅠ 최선을 다하도록 하겟슴돠 <~!~!~