• 검색 결과가 없습니다.

09.Android Client 연습

N/A
N/A
Protected

Academic year: 2021

Share "09.Android Client 연습"

Copied!
7
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Chapter Chapter 신한대학교 2015 봄학기 클라이언트/서버 프로그래밍 고덕윤 [email protected] .

Android Client 연습

9

(2)

안드로이드 클라이언트 사용의 개요

01

• Request and response • RESTfull method call • With JSON

(3)

Android 개발환경 설정

• Genymotion 설치.

https://www.genymotion.com

다운로드

• 다운로드 파일 설치

http://plugins.genymotion.com/eclipse

이클립스 플러그인 설치

• Gson Library

• Google 에서 만든 Json Library.

• Object 에서 Json 전환이 간편하다

• To JSON : new Gson().toJson(Object o)

• To Object : new Gson().fromJson(String json, Class type)

• 인터넷 허용

• Manifest 에 퍼미션 추가

• <uses-permission android:name=

"android.permission.INTERNET"/>

(4)

Android RESTful service 연결

03

serviceURL = new URL(url);

conn = (HttpURLConnection) serviceURL.openConnection(); conn.setRequestProperty("Accept","application/json");

conn.setRequestProperty("Content-Type","application/json");

• 커넥션 얻어오기

• 메소드 설정

conn.setRequestMethod(“POST");

• 커넥션에 필요한 클래스

java.net.HttpURLConnection conn; java.net.URL serviceURL;

(5)

요청과 응답

04

OutputStream os = conn.getOutputStream(); os.write(json.getBytes());

os.flush();

• 요청

• 응답

BufferedReader br = new BufferedReader(new

InputStreamReader(conn.getInputStream()));

while((s = br.readLine()) != null) {

output = output + s; }

(6)

비동기 호출

• Android 에서는 동기화 호출을 허락하지 않음

• 응답이 늦을 경우 안전성의 치명적인 문제

• android.os.AsyncTask<Class inputType, Void, Class outputType>

• AsyncTask.get() : 결과가 도착하면 값을 가져옴

05

요청 응답 요청 응답

(7)

실습 및 기말고사 대체 과제

• 팀 멤버 관리 프로그램을 RESTful 웹 서비스로 변환

• Google app engine 배포

• 안드로이드 클라이언트를 이용하여 • 로그인 기능을 완성하고, (HW3-1) • 회원가입 • 로그인 • (아이디 중복 확인) • 팀멤버 추가 (HW3-2) • 팀멤버 리스트 조회 • 팀멤버 정보 변경 • 팀멤버 삭제 • 기능을 구현한다. • Github 에 소스코드를 업로드 하지 말 것 • Github의 코드를 참조 • https://github.com/maniara/CSP_Class • 제출 • 6/17 23:59 까지 메일로 • 제출시 완료된 부분과 완료되지 않은 부분을 반드시 명시할 것 • 안드로이드 앱의 스크린캡쳐를 첨부할 것.

06

참조

관련 문서

Clozapine 으로 인한 빈맥, 과잉 침 분비 치료 : central alpha-adrenergic agonist. ; anti HBP, central acting analgesic(pain controller)

Inflectional(굴절) Derivational(파생) Grammatical function Lexical function No word class change May cause word class.. change

The self-flushing pump head uses a self-flush seal and secondary set of check valves to create a continuous and positive flow in the area behind the high-pressure pump seal..

단기사용 : severe depression with psychotic features, substance- induced psychosis, aggressiveness &amp; behavioral problems in pervasive developmental disorder

Bluetooth 장치에 무선 연결하는 방법 페어링된 Android 스마트폰에 연결 Bluetooth 연결을 통해 장치에서 음악 듣기 헤드셋을

An Android program generally forms a Java program with APIs in Android platform. Using the APIs, one can build user interfaces to make a phone call, play a game, and so on. An

I have

페놀에 오염된 수 돗물을 마신 수돗물을 마신 시민들은 구토·설사·복통으로 고통을 겪었으며 수돗물로 만든 두부·김치·콩나물 등은 악취 때문에 폐기 처분하는