Advantages: It gives you access to other Android development tools from inside the Eclipse IDE: take screenshots, Debug / set breakpoints, and view thread and process information dir
Trang 15 Using Android OS / Devices
4 Introduction to Android OS
3 Software Installation
2 Mobile / Tablet OSs
6 Eclipse debug with Android app
7 Components of the Android Application
8 Units of measurement
Trang 5Intents, Receivers, Adapters
Explicit Intents
Implicit Intents
Event Broadcasting with Intents
Event Reception with Broadcast Receivers
Adapters and DataBinding
Trang 6Files, Content Providers, Databases
Saving and Loading Files
SQLite Databases
Providers
Content Provider Registration
Native Content Providers
Trang 7Common Android APIs
Trang 8Have an appreciation of the Android OS
Know how to develop basic UIs
Know how to broadcast and receive events
Know how to manage data storage through files,
databases, and content providers
Know how to implement basic location-based
services
Know how to use audio and video utilities
Trang 9Know how to access the Internet
Know how to process URL data encoded in
HTML/XML
Know how to capture touch screen events and
recognize touch screen gestures
Become exposed to Android online resources and
Trang 10[1] Unlocking Android
[2] The Busy Coders Guide to Android Development
[3]Beginning Android Application Development –
Trang 11Attendance
Mid term lab test
Final lab test
Homework
assignments in every week
Final Project
Final project will require technical writing (project
proposal submission, source documentation, description)
Code in java (Eclipse)
There will be reading suggestions
Final test
Trang 12All assignments will be submitted via Hotmail sharing
All assignments using namespace
vn.edu.hui.fit.Studentname.ID labNo
vn.edu.hui.fit.lethihoa.0891233.Lab32
Grades will be submitted via Hotmail sharing
Late submission will not be accepted
Trang 13- Attendance 75%
- Do homework
- Do lab project
- Research on internet
Trang 14MeeGo
IOS WebOS
Android
Trang 15Samsung Closed source
Trang 16C/C++ J2EM
Trang 17Phone C#
VB.net XAML
Trang 18from HP open sourced running on the Linux kernel Visual Studio
C/C++
Java
Trang 19IOS
Apple derived from Mac OS X
Objective C – iPhone SDk
Trang 20BlackBerry
Trang 21Google Inc free and open source Linux-derived OS
Java (Android SDK)
Trang 22Professional Ubuntu Mobile Development
Trang 23open source
Trang 24Not much room
Reuse of common component is impotant
Phone functionality always highest priority
Always on
Trang 253.1 Introdution to software tools
3.2 Install Android SDK
Trang 26 The Android Development Tools (ADT) adds extensions to the Eclipse IDE It allows: create and debug Android applications easier and faster
Advantages:
It gives you access to other Android development tools from inside the Eclipse IDE: take screenshots, Debug / set breakpoints, and view thread and process information directly from Eclipse
It provides a New Project Wizard (you quickly create and set up all
of the basic files you'll need for a new Android application.)
It automates and simplifies the process of building your Android application
It provides an Android code editor that helps you write valid XML for your Android manifest and resource files
export project into a signed APK, which can be distributed to users
Trang 27Tools that help you develop mobile applications on the Android platform
Android Development Tools (ADT) Plugin
Android Emulator
Device
emulation tool that you can use to design, debug, and test your applications in an actual Android run-time environment without an actual phone
Android Virtual Devices(AVDs)
Trang 28OS: Windows (XP or later), Linux (Ubuntu10.10), Mac
Trang 29Java Development Kit (JDK)
Required to develop applications in Java
Contains a Java compiler, debugger, documentation tools, and other tools
Java Runtime Environment (JRE)
Allows you to run a Java application
Trang 30Integrated development environment (IDE)
Similar to Microsoft Visual Studio
Not required for Android development
Alternatives include
Command-line based tools only
Other IDEs, e.g., NetBeans
Google documentation refers to Eclipse extensively
Trang 32Step 1: Install Java Development Kit
download the JDK from
Step 2: Install Eclipse IDE
To download and install Eclipse IDE visit http
The Android SDK Starter Package includes the core SDK tools
This helps in downloading and installing the rest of SDK
components
download the Starter Package from http://
developer.android.com/sdk/index.html
Unpack the downloaded zip file to any suitable location on your
computer (ex: c:\android-sdk-windows)
Trang 33Step 4: Install ADT Plugin for Eclipse
To work with Eclipse IDE you need to install Android
Development Tool (ADT)
To install this plugin Start Eclipse and select Help -> Install New Software-> Click Add button -> Type URL
In the Available Softwares dialog, select the Developer
Tools to install the Android DDMS and Android development Tools
Trang 34Step 5: Set Android Preferences
In Eclipse IDE, select Window -> Preferences Select
Android and browse to the location where Android SDK
was unpacked Press OK button
Trang 35Step 6: Add SDK Components and APIs
Android SDK and AVD Manager is used to add or update
the SDK Components and APIs
In Eclipse IDE, select Window -> Android SDK Manager -> Available Packages
Select the APIs you need to
develop your applications
Trang 36Step 6: Add SDK Components and APIs
Trang 37Step 7: Create Virtual Devices
To run the emulator to run applications, you need to create Virtual Devices You can create multiple devices each with
different configurations as per your need
To define an AVD, in Eclipse IDE,
select Window ->
Android Virtual Devices Manager
Press New button and define the
configuration for your new virtual device
Trang 38Step 7: Create Virtual Devices
Trang 39http:// developer.android.com/sdk/installing/index.html
Read more
Trang 404.1 Reasons to go mobile application development
Trang 42Open software platform for mobile development
created by Google and the Open Handset Alliance
A complete stack – OS, Middleware, Applications, a
large market
Powered by Linux operating system
Fast application development in Java
Open source under the Apache 2 license
Trang 43There exists a great variety of mobile operating
systems: Symbian OS, MS Windows Mobile, Mobile
Linux, iPhone OS, Moblin…
Great market fragmentation
So far no single OS has become the defact to standard (there will ever be one mobile OS; more likely two or
three major mobile OS's and a few minor ones)
Trang 44In 2005, Google acquires the startup company
Android, Inc
In 2005, the work begins on the Dalvik VM and other
components of the Android Platform
In 2007, the Open Handset Alliance is formed by a
group of companies(Sprint, Motorola, Samsung, Sony Ericsson, Google, Intel, Texas Instruments, etc…)
Trang 45The Open Handset Alliance releases a lot of IP through the Apache License, Version2.0
In Nov.2007, the first version of the Android SDK is
released
In Sept.2008, T-Mobile G1 becomes the 1st smartphone with the Android platform (ver 1.0)
In Feb.2009, Android 1.1 is released
In Apr.2009, Android 1.5 Cupcake is released
Trang 46In May.2010, Android 2.2.x Froyo is released
In Dec.2010, Android 2.3.x Gingerbread is released
In Feb.2011, Android 3.x Honeycomb Froyo is released
In Oct.2011, Android 4.0.x Ice Cream Sandwich
is released
In Jul.2012, Android 4.1 Jelly Bean is released
In Nov.2012, Android 4.2 Jelly Bean is released
Trang 48Oct.2011
Jul.2012
http:// en.wikipedia.org/wiki/Android_version_history
Trang 49a group of 47 (Maybe now >47) technology and mobile
companies have come together to accelerate innovation
in mobile and offer consumers a richer, less expensive,
and better mobile experience
developed Android™, the first complete, open, and free mobile platform
commercial deploy handsets and services using the
Android Platform
Trang 50http:// en.wikipedia.org/wiki/Open_Handset_Alliance
Open Handset Alliance Members
Trang 51Android Iphone
Operating Systems:
Android apps can be developed on Windows
,Linux ,and MacOS iPhone apps only on a Mac
Programming Languages:
Android apps can be developed in Java, C/C+
+, and increasingly in Python and Perl Objective C is the only choice for serious iPhone development for now
Source Code Availability:
Android is mostly open source iPhone is 100% proprietary
Third-party Software Distribution:
There is a small entry fee for publishing
Android apps on the Android market there is an Apple-centered certification process to make your apps available in the
AppStore
Trang 52Hardware Choices: Dual-Core CPU, Camera, Audio
device, Bigger Screens…
Pricing
Java for developers
Accessibility: Your Choice of Carriers several
different devices manufacturers like HTC, Motorola and
Samsung They are also available with a choice of
carriers and different plans to suit different users' needs
So, why Android?
Trang 53Application framework enabling reuse and replacement of components
Dalvik virtual machine optimized for mobile devices
Integrated browser based on the open source WebKit engine
Optimized graphics powered by a custom 2D graphics library; 3D graphics
based on the OpenGL ES specification (hardware acceleration optional)
SQLite for structured data storage
Media support for common audio, video, and still image formats (MPEG4,
H.264, MP3, AAC, AMR, JPG, PNG, GIF)
GSM Telephony (hardware dependent)
Bluetooth, EDGE, 3G, 4G, and Wi-Fi (hardware dependent)
Camera, GPS, compass, and accelerometer (hardware dependent)
Trang 54Android Software Stack
Trang 55Linux kernel is a proven core platform
Reliability is more important than performance when it
comes to a mobile phone, because voice communication
is the primary use of a phone
Linux provides a hardware abstraction layer, letting the
upper levels remain unchanged despite changes in the
underlying hardware
Why use Linux for a phone?
Trang 58•C/C++ libraries
•Interface through Java
•Surface manager – Handling UI Windows
•2D and 3D graphics
•Media codecs, SQLite, Browser engine
Trang 59Android Runtime
•Dalvik VM
–Dex files
–Compact and efficient than class files
–Limited memory and battery power
•Core Libraries
–Java 5 Std edition
–Collections, I/O etc…
Trang 60Application Framework
•API interface
•Activity manager – manages application life cycle
Trang 61•Built in and user apps
•Can replace built in apps
Trang 62Dalvik Virtual Machine
Dalvik is the name of a town in Iceland
Dalvik VM is written by Daniel Bornstein
Dalvik VM takes the generated class files and
combines them in to one or more dex files (Dalvik
executables)
It reuses the information from class files to reduce the
size of the footprint
Dalvik VM uses the registers as the primary source of
data storage in stead of the stack (JVM)
Trang 63Android applications are compiled to Dalvik bytecode
Trang 64The Dalvik runtime is optimised for mobile applications
Trang 655.1 Creating Android device without Buying a Phone
5.2 Using Android device
5.3 Using Android virtual device
5.4 Connect and debug on real device
Trang 66Creating Android Virtual Device
Setup account: contact, email
Using market from AVD
Trang 68 Android Desktops
Call, SMS, Contact, Calendar, Email
Gallery, play audio, video file
Change desktop, add widget, copy shortcut to desktop
Using button: home, back, menu
Copy/Paste text between apps
Setting
Using web browser
Application: Install /Uninstall/Move to SD card
Trang 70Ver 1.6
Trang 71Ver 4.0
Trang 72http:// developer.android.com/tools/help/emulator.html
Trang 73Change Android emulator skin
Copy folder in to flatform
Emulator vs Simulator
VirtualPC or Vmware?
Trang 74Emulator looks for the disk
images in the private storage
area of the AVD in use
Trang 75The default storage location for AVDs is in
Users\<user>\.android\avd\
Trang 76android list targets (android-skd\tools)
android list avd
emulator -avd<avd_name>
adb devices
adb shell
Log in AVD shell (1)
adb –s emulator-5554 shell
telnet localhost 5554
smssend <Sender’s phone number> <text message>
gsmcall <caller’s phone number>
You must setup Environment variables to use adb command line
Trang 77accepts a number of Linux shell commands in Android Emulator:
Trang 78DDMS – Emulator Control
Trang 79DDMS-File Explorer
Trang 80 3G icon on AVD
Path data/data (permission) on File Explorer in DDMS
Send sms from 2 AVDs
Copy image/media file to AVD
Trang 81Install from unknown source
Setting debug mode
ADB driver
Debug in eclipse
Trang 82< application
android:icon ="@drawable/ic_launcher"
android:label ="@string/app_name"
android:debuggable = "true">
Trang 84A View is a UI building block: a text field, a label, a
button, …
Views are hierarchical objects that know how to draw
themselves
In MS GUI lingo, views are controls
Trang 85An Activity is a single screen in an application
An Activity typically contains at least one view
An application may have several activities
Trang 86A Message object that announces an intention
An Intent can broadcast a message
An Intent can start a service
An Intent can launch an activity
Intents are initiated by applications
Intent
Trang 87 IntentFilters
An Intent is a declaration of need
An Intent is made up of various pieces including:
–desired action or service,
–data, and
–category of component that should handle the intent
and instructions on how to launch a target activity
An IntentFilter is a trigger, a declaration of capability
Trang 88A Mechanism (essentially, an API) for applications to
share data without exposing the underlying storage
details
The underlying data can be stored in a file or a database
Trang 89A Background process
not interacting with the user
for an indefinite period of time
like other application objects, run in the main thread of their hosting process
Example: an email application that polls for new message
Local services are services accessible to the hosting
application
Remote services are services that can be used by other
Trang 90If an application wants to receive and respond to a global event, such as the phone ringing or an incoming text
message, it must register as a BroadcastReceiver
An application may register at runtime
Or register at the AndroidManfest.xml file
it does not have to be running
When the global event occurs, the application is started automatically upon notification of the triggering event All
of this housekeeping is managed by the Android OS
itself
do not have a UI
Trang 91An XML file that defines the contents and behavior of
the application
It names the Java package for the application (unique
identifier for the application.)
It declares the minimum level of the Android API that
the application requires
It contains the list of activities in the application
It describes the components of the application —the
Trang 92It declares IntentFilter
It declares which permissions the application must
have in order to access protected parts of the API and
interact with other applications
It also declares the permissions that others are
required to have in order to interact with the
application's components
It lists the libraries that the application must be linked
against
…
Trang 93Go Here Auto gen
Android libs
Resource
Layout