1. Trang chủ
  2. » Ngoại Ngữ

Android development introduction

85 267 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 85
Dung lượng 2,45 MB

Nội dung

Android Development Introduction Notes are based on: Unlocking Android by Frank Ableson, Charlie Collins, and Robi Sen ISBN 978-1-933988-67-2 Manning Publications, 2009 & Android Developers http://developer.android.com/index.html Chapter - Goals THE BIG PICTURE What is Android? Overview development environment Chapter - Resources Android’s web page http://www.android.com/ What is Android? • Android is an open-source software platform created by Google and the Open Handset Alliance • It is primarily used to power mobile phones • It has the capability to make inroads in many other (non-phone) embedded application markets What is Android? • Android™ consists of a complete set of software components for mobile devices including: – an operating system, – middleware, and – embedded key mobile applications – a large market Why Android? Listen from the project creators/developers – – – – – – – – – • • (2.19 min) Nick Sears Co-founder of Android Steve Horowitz Engineering Director Dam Morrill Developer Peisun Wu Engineering Project Manager Erick Tseng Project Manager Iliyan Malchev Engineer Mike Cleron Software Manager Per Gustafsson Graphics Designer etc… http://www.youtube.com/watch?v=6rYozIZOgDk&eurl=http://www.android.com/about/&feature=player_embedded You will hear statements such as “…currently it is too difficult to make new products … open software brings more innovation … choices … lower costs … more applications such as family planner, my taxes, understand my wife better, … ” What is Open Handset Alliance? • Quoting from www.OpenHandsetAlliance.com page • “… Open Handset Alliance™, a group of 47 technology and mobile companies have come together to accelerate innovation in mobile and offer consumers a richer, less expensive, and better mobile experience • Together we have developed Android™, the first complete, open, and free mobile platform • We are committed to commercially deploy handsets and services using the Android Platform “ Open Handset Alliance Members Operators Software Co Commercializat Semiconductor Handset Manf China Mobile Ascender Corp Aplix Audience ACER China Unicom eBay Noser Engineering Broadcom Corp ASUS KDDI Corp Esmertec Astonishing Tribe Intel Corp HTC NTT DoCoMo Google Wind River Systems Marvell Tech Group LG Sprint Nextel LivingImage Omron Software Nvidia Corp Motorola T-Mobile NMS Comm … Qualcomm Samsung Telecom Italia Nuance Comm Teleca SiRF Tech Holdings ASUSTek Telefónica PacketVideo Synaptics Garmin Vodafone SkyPop Texas Instr Huawei Tech Softbank SONiVOX AKM Semicond LG … … ARM Samsung Ericsson Borqs Atheros Comm … Sony Ericsson EMP Toshiba See Android Developers http://www.youtube.com/watch?v=7Y4thikv-OM Short video (4 min.) Showing Dave Bort and Dan Borstein, two members of the Android Open Source Project talk about the project The Android Platform Again, what did they say about Android? • • • • Android is a software environment built for mobile devices It is not a hardware platform Android includes: • • • • • • • Linux kernel-based OS, a rich UI, telephone functionality, end-user applications, code libraries, application frameworks, multimedia support, User applications are built for Android in Java 10 Android Manifest xml File • Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory • The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code 71 Android Manifest xml File These are the only legal elements; you cannot add your own elements or attributes 72 Android Manifest xml File Các tác dụng quan trọng manifest: – Đặt tên cho Java package ứng dụng Tên package đóng vai trò định danh cho ứng dụng – Mô tả component ứng dụng – activity, service, broadcast receiver, content provider ứng dụng – Gọi tên class cài đặt component khai báo lực chúng (capability) (ví dụ, chúng xử lý Intent nào) Các khai báo cho phép hệ thống Android biết có component chạy chúng điều kiện – Quyết định tiến trình chứa component ứng dụng – Khai báo permission mà ứng dụng phải cấp để truy nhập phần bảo vệ API tương tác với ứng dụng khác – Khai báo permission mà ứng dụng khác phải có để tương tác với component ứng dụng hành – Liệt kê lớp Instrumentation cung cấp thông tin khác ứng dụng chạy Các khai báo có manifest ứng đụng phát triển test; chúng bị xóa trước ứng dụng phát hành – Khai báo minimum level Android API mà ứng dụng yêu cầu – Liệt kê library mà ứng dụng cần link với 73 Android Manife File 74 Example Currency converter Implementing a simple currency converter: USD – Euro – Colon (CR) Note Naive implementation using the rates Costa Rican Colon = 0.001736 U.S dollars Euro = 1.39900 U.S dollars 75 Example Currency converter 76 Example Currency converter package matos.currencyconvereter; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Currency1 extends Activity { // naive currency converter from USD to Euros & Colones final double EURO2USD = 1.399; final double COLON2USD = 0.001736; // GUI widgets Button btnConvert; Button btnClear; EditText txtUSDollars; EditText txtEuros; EditText txtColones; 77 Example Currency converter @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // bind local controls to GUI widgets txtUSDollars = (EditText)findViewById(R.id.txtUSDollars); txtUSDollars.setHint("Enter US dollars"); txtEuros = (EditText)findViewById(R.id.txtEuros); txtColones = (EditText)findViewById(R.id.txtColones); // attach click behavior to buttons btnClear = (Button)findViewById(R.id.btnClear); btnClear.setOnClickListener(new OnClickListener() { // clear the text boxes @Override public void onClick(View v) { txtColones.setText(""); txtEuros.setText(""); 78 txtUSDollars.setText(""); Example Currency converter // the conversion from USD to Euros and Colones btnConvert = (Button) findViewById(R.id.btnConvert); btnConvert.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { String usdStr = txtUSDollars.getText().toString(); double usd = Double.parseDouble( usdStr ); String euros = String.valueOf( usd / EURO2USD ); String colones = String.valueOf( usd / COLON2USD ); txtEuros.setText(euros); txtColones.setText(colones); } catch (Exception e) { Toast.makeText(v.getContext(), "Invalid data - try again" , Toast.LENGTH_SHORT).show(); } } });// setOnClick }// onCreate }// class 79 Example Currency converter 80 Example Currency converter Resource: res/ layout/main.xml (1/2) 81 Example Currency converter Resource: res/ layout/main.xml (2/2) 82 Example Currency converter 83 Additional Resources Google Developer Conference San Francisco – 2009 Web page: http://code.google.com/events/io/ 84 Questions ???? 85 [...]... http://sites.google.com/site/io/inside-the -android- application-framework Android is designed to be fast, powerful, and easy to develop for This session will discuss the Android application framework in depth, showing you the machinery behind the application framework explains the life-cycle of an android apk very good! 22 Android Components Video: An Introduction to Android (about 52 min) Presented by Jason... accelerometer (hardware dependent) • Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE 17 Android Components 18 Android Components Video 1/3: Android s Architecture Presented by Mike Cleron, Google Corp (13 min) Available at: http://www.youtube.com/watch?v=QBGfUs9mQYY 19 Android Components Video 2/3: Application’s... Google Corp (8 min) 20 Available at: http://www.youtube.com/watch?v=fL6gSd4ugSI&feature=channel Android Components Video 3/3: Android s API Presented by Mike Cleron, Google Corp (7 min) Available at: http://www.youtube.com/watch?v=MPukbH6D-lY&feature=channel 21 Android Application Framework Video: Inside the Android Application Framework (about 52 min) Presented by Dan Morrill – Google At Google Developer... Psychologist / Mentor / Adviser ???? 13 Android vs Competitors 1 Apple Inc 2 Microsoft 3 Nokia 4 Palm 5 Research In Motion 6 Symbian 14 The Size of the Mobile Market http://gizmodo.com/5489036/cellphone-overshare [see appendix] 15 15 Android Components (Stack) • • The Android stack includes a large array of features for mobile applications It would be easy to confuse Android with a general purpose computing... Virtual Machine • User application, cũng như các ứng dụng core Android, được viết bằng Java và được dịch thành byte code • Android byte code được thông dịch tại thời gian chạy bởi máy ảo Dalvik (Dalvik virtual machine) • Tại sao dùng một máy ảo khác? – Các file bytecode Android tương đương về lô-gic với Java bytecode, nhưng chúng cho phép Android • • Chạy các ứng dụng trong môi trường ảo của riêng nó,... startActivity(myIntent); 34 Example of Intent (1) Intent uses ACTION_VIEW to see Contacts 35 Example of Intent (1) • Complete code to see Contacts package matos.cis493; import android. app.Activity; import android. content.Intent; import android. net.Uri; import android. os.Bundle; public class AndDemo1 extends Activity { /** show contact list */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);... VM Internals Presented by Dan Borstein At Google Developer – 2008 San francisco Available at: http://www.youtube.com/watch?v=ptjedOZEXPM 26 Inside Android: Intents • • • Chủ đề quan trọng hay gặp trong phát triển ứng dụng Android là Intent Một Intent trong Android mô tả cái ta muốn làm Có thể là – – – • “Tôi muốn tra cứu một mục trong contact record,” hoặc “Hãy mở website này,” hoặc “Mở màn hình khẳng.. .Android s Context: Mobile Market Player$ Stakeholders: Mobile network operators want to lock down their networks, controlling and metering traffic Device manufacturers want to differentiate themselves... record,” hoặc “Hãy mở website này,” hoặc “Mở màn hình khẳng định đơn đặt hàng.” Tầm quan trọng của intent : chúng cho phép di chuyển điều khiển trong ứng dụng và là khía cạnh quan trọng nhất trong lập trình Android 27 Intents & IntentFilters • An Intent is a declaration of need • Một Intent bao gồm các mẩu thông tin sau: – – – action hay service muốn thực hiện, data – dữ liệu vào cho action/service đó, và... Implicit intent không gọi tên component đích (trường dành cho tên component để trống), thường được dùng để kích hoạt các component trong các ứng dụng khác Late binding được áp dụng ở đây Mỗi khi có thể, Android sẽ gửi explicit intent cho một thực thể của lớp đích được chỉ định 33 Example of Intent (1) • Following fragments calls an Intent whose job is to invoke a built-in task (ACTION_VIEW) and explore

Ngày đăng: 25/08/2016, 19:01

TỪ KHÓA LIÊN QUAN

w