1 / 15

2. 개발 환경 구축

2. 개발 환경 구축. 안드로이드 패키지 (1/2). 안드로이드 패키지 - android.app – 안드로이드 애플리케이션 모델 접근 - android.content – 안드로이드에서 데이터 접근과 추출 관련 - android.net – URI 클래스를 포함하여 다양한 콘텐츠에 접근하는데 사용 - android.graphics – 그래픽 패키지 관련 - android.opengl – OpenGL 관련 클래스들 (3D 그래픽 관련 )

kiora
Download Presentation

2. 개발 환경 구축

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2. 개발 환경 구축

  2. 안드로이드 패키지 (1/2) 안드로이드 패키지 - android.app – 안드로이드 애플리케이션 모델 접근 - android.content – 안드로이드에서 데이터 접근과 추출 관련 - android.net – URI 클래스를 포함하여 다양한 콘텐츠에 접근하는데 사용 - android.graphics – 그래픽 패키지 관련 - android.opengl – OpenGL관련 클래스들 (3D 그래픽 관련) - android.os – 시스템 레벨의 안드로이드 개발 환경에 접근하는데 사용 - android.provider – 콘텐트 프로바이더 관련 클래스 - android.telephoney – 전화기능 접근 - android.text – 텍스트 레이아웃 - android.util – XML을 포함한 텍스트 처리 관련 유틸리티 모음 - android.view – UI 요소들 - android.webkit – 브라우저 기능 - android.widget – 추가 UI 요소들 Unlocking Android

  3. 안드로이드 패키지 (2/2) Java 패키지 - java.lang – 자바의 핵심 언어관련 클래스 - java.io – 입/출력 기능 - java.net – 네트워크 연결 - java,util – 유틸리티 클래스 - java.text – 문자 처리관련 유틸리티 - java.math – 수학 및 수와 관련된 클래스들 부가 패키지 - GPS - 블루투스(Bluetooth) - 적외선(IrDA) - 무선랜(Wi-Fi) Unlocking Android

  4. 이클립스 자바 소스 편집, 클래스 자동완성 기능, javadoc등을 포함한 편리한 자바 개발 환경 제공 소스 레벨 디버깅 안드로이드 에뮬레이터 프로파일 관리 및 실행 DDMS(Dalvik Debug Monitoring System) - 스레드, 힙뷰 제공 - 에뮬레이터 파일 시스템 관리 - 데이터 & 음성 네트워크 관리 - 에뮬레이터 관리 - 시스템 & 애플리케이션 로깅 Unlocking Android

  5. 이클립스퍼스펙티브(1/2) 자바 퍼스펙티브 - 자바 소스코드의 작성 - 소스코드의 저장과 동시에 JDT(Java Developer Tools)에 의해 자동으로 컴파일 - 패키지 익스플로러 - Problems 뷰 - Javadoc뷰 DDMS퍼스펙티브 - 안드로이드 디바이스의 내부 정보 제공 - 디바이스 뷰 - Logcat뷰 - 파일 익스플로러 - 에뮬레이터 컨트롤 Unlocking Android

  6. 이클립스퍼스펙티브(2/2) 디버그 퍼스펙티브 - 이클립스의 빠른 실행 아이콘에서 ‘벌레’모양의 아이콘 선택 - 다른 디버거와 마찬가지로 한 라인씩 실행, 다음 단계로 넘어가기, 메서드 호출, 변수 값 확인 기능 제공 - 브레이크 포인트 설정 가능 Unlocking Android

  7. 커맨드라인 도구 AAPT(Android Asset Packaging Tool) : pkzip, jar 등의 압축 관련 기능과 안드로이드용 리소스 컴파일러 기능 결합 AAPT(Android Asset Packaging Tool) - 커맨드라인 또는 스크립트를 통해 안드로이드 에뮬레이터 와 상호 작용 도와줌 - TCP 기반의 Client/Server 프로그램 - 실행 중인 안드로이드 에뮬레이터의 인스턴스에 접근 가능 Unlocking Android

  8. 안드로이드 프로젝트 마법사 이클립스의[File – New – Android Priject] 메뉴를 선택하면 프로젝트 마법사 실행 프로젝트 마법사의 구성요소 - Project Name : 이클립스의 프로젝트 명 - Package Name : 자바패키지 지정 - Activity Name : 기본으로 생성되는 액티비티 클래스 이름 - Application Name : 스마트폰에서 사용되는 애플리케이션 이름 Unlocking Android

  9. 예제 코드 구성요소 - src : 마법사에의해 생성된 두 개의 자바 소스 파일 - ~ .java : 애플리케이션을 위한 메인 액티비티 포함 - R.java : 애플리캐이션의UI 리스소 정보. 수정X - android.jar : 안드로이드 런타임 자바 클래스 - res : 모든종류의 안드로이드 리소스 파일 포함 - drawables : 비트맵 이미지, 아이콘과 같은 이미지 파일 포함 - layout : 액티비티의 메인 뷰를 위한 UI 엘리먼트를 기술하는 main.xml 파일 포함 - value : 애플리케이션에서 사용될 문자열 데이터를 가진 strings.xml 파일 포함 - AndroidManifest.xml : 애플리케이션의 구성 요소에 대한 정보 Unlocking Android

  10. main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayoutxmlns:android=http://schemas.android.com/apk/res/android android:orientation="vertical“ // 4개의 뷰를 수직 방향으로 순서대로 나열 android:layout_width="fill_parent“ android:layout_height="fill_parent”> <TextView// 지정된 문자열을 출력하기 위한 android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Chapter 2 Android Tip Calculator” /> <EditText// 사용자로부터 데이터를 입력받기 위한 android:id="@+id/mealprice“ // 리소스 클래스에 mealprice에 대한 id 할당 android:layout_width="fill_parent" android:layout_height="wrap_content" android:autoText="true” /> <Button // calculate id를 가진 Button 정의 android:id="@+id/calculate“ android:layout_width="wrap_content" android:layout_height="wrap_content“ android:text="Calculate Tip” /> <TextView// answer id를 가진 TextView정의 android:id="@+id/answer“ android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=“” /> </LinearLayout> id를 갖는 요소들은 애플리케이션이 실행되는 과정에서 UI 엘리먼트에 대한 동적인 참조가 이루어짐 Unlocking Android

  11. ChapterTwo.java (1/3) package com.manning.unlockingandroid; // 패키지 이름 import java.text.NumberFormat; // 필요한 클래스들 import import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class ChapterTwo extends Activity { // Activity 클래스 상속 public static final String tag = "Chapter2"; /** Called when the activity is first created. */ @Override // 부모클래스의 메소드를 public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); final EditTextmealpricefield = // UI 구성요소들에 대한참조 설정 (EditText) findViewById(R.id.mealprice); final TextViewanswerfield = (TextView) findViewById(R.id.answer); final Button button = (Button) findViewById(R.id.calculate); Unlocking Android

  12. ChapterTwo.java (2/3) button.setOnClickListener(new Button.OnClickListener() { // 버튼의 OnClickListener설정 public void onClick(View v) { try { // Perform action on click Log.i(ChapterTwo.tag, "onClick invoked."); // Log함수 사용 // grab the meal price from the UI String mealprice = mealpricefield.getText().toString(); Log.i(ChapterTwo.tag, "mealprice is [" + mealprice + "]"); String answer = ""; // check to see if the meal price includes a "$“ if (mealprice.indexOf("$") == -1) { mealprice = "$" + mealprice; } float fmp = 0.0F; // get currency formatter NumberFormatnf = java.text.NumberFormat.getCurrencyInstance(); if (nf == null) { Log.i(ChapterTwo.tag, "punt - NumberFormat is null"); } // grab the input meal price fmp = nf.parse(mealprice).floatValue(); // let's give a nice tip -> 20% fmp *= 1.2; Log.i(ChapterTwo.tag, "Total Meal price (unformatted) is [" + fmp + "]"); 사용자가 입력한 mealprice가져오기 사용자가 입력한 문자가 $ 표시가 아니면 앞에 표시되도록 20% 의 팁을 포함한 가격 계산을 위해 Unlocking Android

  13. ChapterTwo.java (3/3) // format our result answer = "Full Price, Including 20% Tip: " + nf.format(fmp); // display the answer answerfield.setText(answer); // 팁을 포함한 전체 가격 출력 Log.i(ChapterTwo.tag, "onClick complete."); } catch (java.text.ParseExceptionpe) { // 에러처리 Log.i(ChapterTwo.tag, "Parse exception caught"); answerfield.setText("Failed to parse amount?"); // 입력된 값이 잘못되었을 경우 출력 } catch (Exception e) { Log.e(ChapterTwo.tag, "Failed to Calculate Tip:" + e.getMessage()); e.printStackTrace(); answerfield.setText(e.getMessage()); } } }); } } Unlocking Android

  14. 안드로이드 패키지 생성 과정 안드로이드 애플리케이션은 자바코드로 기술되고 안드로이드 전용의 dex파일로 컴파일되어달빅가상머신 위에서 실행 애플리케이션의 리소스 파일들은 AADT에 의해 처리되어 R.java 파일 생성 자바소스들은 JDT에 의해 클래스 파일들로 컴파일 XML 파일은 바이너리 형태로 변환 리소스와 클래스 파일들은 AAPT에 의해 패키징되어 projectname.apk 파일로 변환 Unlocking Android

  15. 네트워크 속도 시뮬레이션 실제 장치 사용 중 발생할 수 있는 다양한 상황 점검 안정적으로 네트워크를 사용할 수 없는 상황에 대한 점검 안드로이드 에뮬레이터는 다양한 네트워크 환경과 속도를 설정하기 위한 도구 제공 Unlocking Android

More Related