Slide android application and rest service 0503

Post on 22-Jan-2018

275 views 0 download

Transcript of Slide android application and rest service 0503

ANDROID APPLICATION AND REST SERVICE

Trình bày: Trang Hồng SơnEmail: tranghongson@gmail.com

THÔNG TIN CHUNG

Nội dung

[1] Bài giảng “Lập trình Android”, Trung tâm tin học - Trường Đại học Khoa học tự nhiên TPHCM.

[2] Tutorial “Development and Deployment of REST Web Services in JAVA”, Software Engineering Competence Center.

[3] https://en.wikipedia.org/wiki/JSON

ANDROID [1] REST SERVICE [2] JSON [3]

ANDROID

vs

REST SERVICE

ANDROID

Android - Lịch sử phát triển

Năm 2003, Android Inc. được thành lập bởi Andy Rubin, Rich Miner, NickSears và Chris White tại California.

Năm 2005, Google sở hữu Android cùng với các vị trí quản lý.

Năm 2007, OHA (Open Handset Alliance) được thành lập bởi Google cùng vớinhiều nhà sản xuất thiết bị phần cứng, thiết bị không dây và vi xử lý. Công bốnền tảng phát triển Android.

Năm 2008, thiết bị HTC Dream là phiên bản thế hệ đầu tiên hoạt động với hệđiều hành Android 1.0.

Năm 2010, Google khởi đầu dòng thiết bị Nexus với thiết bị đầu tiên của HTClà Nexus One.

Năm 2013, ra mắt loạt thiết bị phiên bản GPE.

Năm 2014, Google công báo Android Wear, hệ điều hành dành cho các thiếtbị đeo được.

Android – Các phiên bản Android

Android - Xu thế phát triển công nghệ di động

Android - Xu thế phát triển công nghệ di động

Android - Xu thế phát triển công nghệ di động

Tổng dân sốđang sử

dụngSmartphone

Người dùngSmartphone sử

dụng dịch vụ tìmkiếm địa điểm trên

điện thoại

Người dùngSmartphone tra cứuthông tin sản phẩmtrên điện thoại của

họ

Người dùngSmartphone thanhtoán trực tiếp trênđiện thoại của họ

20% 97% 95% 60%

SỬ DỤNG SMARTPHONE

Android - Xu thế phát triển công nghệ di động

278%266%

247%237%

211% 209% 209%

189%182% 177% 176% 171%

0

50

100

150

200

250

300

Fastest Growing iOS & Android Markets by Active Devices (%)

Colombia Vietnam Turkey Ukraine Egypt China Chile India Venezuela S. Africa Thailand Philippines

Android - Xu thế phát triển công nghệ di động

Android - Thị trường thiết bị Android

Android - Kiến trúc Android

Android được hình thành dựa trên nền tảng Linux nhân 2.6, từ phiên bản

4.0 sử dụng Linux nhân 3.x.

Android bao gồm 3 thành phần chính:

o Middleware

o Các thư viện và API viết bằng C

o Các ứng dụng thực thi viết bằng Java

Sử dụng máy ảo Dalvik để biên dịch mã .dex (Dalvik Excuteable) sang

Java bytecode.

Android - Kiến trúc Android

Android - Ngôn ngữ lập trình

Java C/C++ JNI

XMLRender Script

Android

MÔI TRƯỜNG PHÁT TRIỂN ỨNG DỤNG

Android Developer Tools Bundle (ADT)

Android Studio

REST SERVICE

Rest Service

It was first introduced in 2000 by Roy Fielding at the University ofCalifornia.

REST (Representational State Transfer) is a technology relies on astateless, client-server, cacheable communications technology thatuses the HTTP protocol.

REST is considered as an architectural style for developingapplications that communicate over the network.

Rest Service

It defines a set of architectural principles by which you can design web

services that focus on the concept of system's resources, including how

resource states are addressed and transferred over the HTTP protocol by

various client applications written in different programming languages.

In REST, the web services are viewed as resources and can be identified by

their URLs (sometimes called URIs). Web service clients that want to use

these resources and access a particular representation will need to use a

globally defined set of remote methods that describe the action to be

performed on the resource.

Rest Service

Similar to "methods" or "services" used in Remote Procedure Call (RPC) and

SOAP Web Services, to access the price of a product, do not need to call a

"getProductName" and then a "getProductPrice" RPC calls; rather, can view

the product data as a resource by just calling a GET request for this URI, and

this resource should contain all the required information.

RESTful applications use HTTP requests to post data (create and/or

update), read data (like queries), and delete data. Thus, REST uses HTTP for

all four CRUD (Create/Read/Update/Delete) operations, so it is lightweight

and simple alternative to the complex mechanisms stated above.

Rest Service

REST COMMUNICATION MODEL

JSON

JSON

JSON (JavaScript Object

Notation) is an open-standard

format that uses human-readable

text to transmit data objects

consisting of attribute–value

pairs.

JSON is a language-independent

data format, is the most common

data format used for client/server

communication, largely replacing

XML.

ANDROIDvs

REST SERVICE

Android vs Rest Service

REST as Lightweight Web Services:

o Platform-independent (you don't care whether the server is Unix, the

client is MacOS, or Windows),

o Language-independent (C# can talk to Java, ...),

o Standards-based (runs on top of HTTP, XML, JSON, …),

o Easily used in the presence of firewalls, as it is simply using the popular

HTTP protocol that can bypass any firewalls used.

Advantages of using REST in Android:

o Make client more lightweight

o Re-usage of existing functionalities

o Remote DB hit made simple

Android vs Rest Service

Android vs Rest Service

Building ANDROID application vs REST service:

o Create Website

Implement REST services in the Website

Deploy Website on the host

o Create ANDROID application to invoke REST services

Demo

Cám ơn sựlắng nghe và chia sẻ !!!

Trình bày: Trang Hồng SơnEmail: tranghongson@gmail.com