Android - iba-s12

Download Report

Transcript Android - iba-s12

Android
Introduction to Android
Mobile application development
• Mobile application development is the
process by which application software is
developed for small low-power handheld
devices such as personal digital assistants,
enterprise digital assistants or mobile phones.
These applications are either pre-installed on
phones during manufacturing, or downloaded
by customers from various mobile software
distribution platforms
Execution Enviornment
• Android
• Ios(Xcode is the development environment for the iOS
SDK. )
• BlackBerry(Third-party developers can write software
using the available BlackBerry classes,)
• HP webOS
• Symbian OS.(February 11, 2011, Nokia announced that
it would migrate away from Symbian to Windows
Phone 7, Symbian platform was created by merging
and integrating software assets contributed by Nokia,
NTT DoCoMo, Sony Ericsson and Symbian Ltd).
• Windows Mobile
• Continued :
Android, Blackberry and J2ME uses Java Language for
their development but their applications are not
portable because of different hardware, SDK and API.
Windows Phone 7 requires Windows Operating
system for its development, the Visual Studio (only
supported IDE for Windows Phone) and Emulator also
works only in Windows environment. C# is the
language of Windows Phone 7 which is not used by
any other platform. iPhone requires Macintosh
Operating System and XCode is the IDE for iPhone.
Objective C is used for the development of iOS
Android
• Android is an open source software stack that
includes the operating system,middleware
and the key mobile applications along with a
set of API libraries.
Android
• A free open source operating system for mobile
devices
• An open source development platform for
creating mobile applications.
• Devices, particularly mobile phones, that run the
android operating system and the applications
created for it.
What is Android
• A software platform and operating system for mobile devices
• Based on the Linux kernel
• Developed by Google and later the Open Handset Alliance
(OHA)
• Allows writing managed code in the Java language
• Possibility to write applications in other languages and compiling
it to ARM native code (support of Google? No)
• Unveiling of the Android platform was announced on 5
November 2007 with the founding of OHA
Introduction
• Android is an operating system based on Linux with a
Java programming interface.
• The Android Software Development Kit (Android SDK)
provides all necessary tools to develop Android
applications. This includes a compiler, debugger and a
device emulator, as well as its own virtual machine to
run Android programs.
• Android is officially guided by the Open Handset
Alliance. In reality Google leads the project.
• Android allows background processing, provides a rich
user interface library, supports 2-D and 3-D graphics
using the OpenGL libraries, access to the file system
and provides an embedded SQLite database.
Open handset alliance
• A commitment to openness, a shared vision for the future, and
concrete plans to make the vision a reality.
• Welcome to the Open Handset Alliance™, a group of 84 technology
and mobile companies who 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.
introduction
• What is the Open Handset Alliance (OHA)?
It's a consortium of several companies
History of Android
• 2005 Google buys Android, Inc. The world thinks a "gPhone" is
about to come out…
• Everything goes quiet for a while.
• 2007 Open Handset Alliance is announced. Android is officially
open-sourced.
• 2008 Android SDK 1.0 is released. The G1 phone, manufactured by
HTC, and sold by the wireless carrier T-Mobile USA, follows shortly
afterwards.
• 2009 sees a proliferation of Android-based devices. New versions of
the operating system: Cupcake (1.5), Donut (1.6), and Eclair (2.0 and
2.1) are released. 20+ devices run Android.
• 2010 Android is 2nd only to RIM as best-selling smart phone
platform. Froyo (Android 2.2) is released and so are 60+ devices
that run it.
What a Desserts (:-
Android SDK Features
Android SDK features
• The true appeal of Android as a development enviornment lies in the
APIs It provides.
1. No licensing,distribution or development fees or release approval
processes
2. Wi-fi hardware access
3. GSM,EDGE and 3G netoworks for telephony or data transfer
enabling you to make or receive the calls or SMS messages or to
send or retrieve data across mobile networks.
4. Comprehensive API for location based services such as GPS
5. Full multimedia hardware control ,including playback and recording
with the camera and microphone
6. APIs for using sensor hardware,including accelometers and the
compass
7. Libraries for using the Bluetooth for peer to peer data transfer.
8. IPC message passing
9. Shared data store
• Continued
10. Backgroun applications and processes
10. An integrated open source HTML5 web kit based
browser
11. Full support for applications that integrate map
controls as part of their user interface
12. Support for 2D and 3D graphics.
13. Media libraries for playing and recording a variety of
audio/video or still image formats
14. Localization through a dynamic resource framework
15. An application framework the encourages reuse of
application compnents and the replacement of native
applications.
Access to hardware ,including camera ,GPS and
Accelerometer(SDK FEATURES )
• The android SDK includes APIs for location
based hardware(such as GPS),the
camera,audio,network connections,wi-fi
,bluetooth,accelometers , touchscreen and
power management.
Background services(Features)
• Android supports applications and services
designed to run invisibly in the backgroun.
• Background services make it possible to create
invisible application component that perform
automatic processing without direct user
interaction,Backgound execution allows your
applications to become event driven and to
support regular updates,which is perfect for
market prices,gererating location-based
alertsor prioritizing and prescreening
incoming calls and sms messages
SQLite Database for Data Storage and
Retreival(Features)
• Android provides a lightweight relational
database for each application using SQLite,your
application can take advantage of this managed
relational database engine to store data securely
and efficiently.
• By default each application database is
sandbox,its contents is available only to the
application that created it -----but content
providers supply a mechanizm for the managed
sharing of these application databases.
Share Data and interapplication
communication(Features)
• Android include three techniques for
transmitting information from your
application for use elsewhere---Notifications,Intents,and content providers.
Android Applications
Native Android Applications
• An e-mail client
• An SMS management application
• A full PIM (personal information management)suite
including a calendar and contacts lists
• A Webkit-based web browser
• A music player and picture gallery
• A camera and video recording applications
• A calculator
• The home screen
• An Alarrm clock
• Android is designed to support a large variety
of hardware platforms,from WVGA phones
with hard keyboards to QVGA devices with
resistive touchscreens
Proprietary Android Applicatiosn
• Android Market Client:-for downloading third-party
Android applicatiosn.
• Google Maps:-application including street view,driving
directions,satellite view and traffic conditions.
• Gmail mail Client
• Google Talk instant-messaging client
• YouTube video player.
The open source nature of android means that carriers and OMEs can
customize the user interface and the applications bundled with each
Android device,Several OEMs have done this ,icluding HTC with the Sense
UI,Motorala with MotoBlur and sony Ericssons custom UI.
The look and feel of userinterface may vary,but your application will function in
the same way across all compatible android devices (it means all compatible
devices remains consistent across OEM and carrier varriation.
First android phone(T-mobile G1)
Android Application Development
Process
How mobile application runs
The APK
• An application is a single APK (application package) file. An APK file
roughly has three main components. It consists of all your Dalvik
executable code (Java code compiled automatically to Dalvik
executable) plus all your resources (everything that is not code,
such as images, layouts, etc.). Additionally, it may contain some
native code as well.
Dalvik executable: this is all your Java source code compiled down to
Dalvik executable. This is the code that runs your application.
• Resources: resources are everything that is not code. Your
application may contain number of images, audio/video clips, as
well as numerous XML files describing layouts, language packs, and
so on. Collectively, these items are resources.
• Native libraries: optionally, your application may include some
native code, such as C/C++ libraries. These libraries could be
packaged together with your APK file.
Intro to development framework
• Android applications are written with java as
programing langurage but executed by a custeom
virtual machine called Dalvik rather than by a java
VM.
• Each android application runs in a separate
process with in its own Dalvik instance
,relinquishing all responsibility for memory and
process management to the Android run
time,which stops and kills process as necessary to
manage the resources
continued
• Dalvik and android run time sits at the top of
the linux kernel that handles the lowlevel
hardware interaction,including the drivers and
memory management ,while a set of APIs
provides access to all the underlying services
,features and hardware.
How to develop android application
Android applications are primary written in the Java programming language. The Java
source files are converted to Java class files by the Java compiler.
Android provides a tool dx which converts Java class files into a dex (Dalvik
Executable) file. All class files of one application are placed in one compressed
.dex file. During this conversion process redundant information in the class files
are optimized in the .dex file. For example if the same String in different class file
is found, the .dex file is stored only once and reference this String in the
corresponding classes.
.dex files are therefore much smaller in size then the corresponding class files.
The .dex file and the resources of an Android project, e.g. the images and XML files
are packed into an .apk (Android Package) file. The program aapt (Android Asset
Packaging Tool) perform this packaging.
The resulting .apk file contains all necessary data to run the Android application and
can be deployed to an Android device via the "adb" tool.
The Android Development Tools (ADT) allows that all these steps are performed
transparent to the user; either within Eclipse or via the command line.
If you use the ADT tooling you press a button or run a script and the whole Android
application (.apk file) will be created and deployed.
Software Development Kit
(SDK)
SDK
• Android software development kit includes
everything you need to start
developing,testing,and debugging Android
application,it includes
• Android APIs:-libraries that provide developer
access to the Android Stack.These are the
same libraries used at google to create native
android applications
• Development Tools:-so you can turn android source
code into executable Android applications,the SDK
includes several development tools that let you
compile and debug your application.
• The Android Virtual Device Manager and Emulator:All android application run with in the Dalvik VM.
Full Documentation:Sample code
Online support
SDK
• SDK includes everything that you need to start
developing,testing and debuging android
applications
• Android API’s:The core of SDK is android APIs
libraries that provide developer access to the
Android stack.
• Development tools:
• The android virtual device manager and Emulator:
FullDocumentation:
Samplecode
Online support
Android Software Stack
Linux kernel
• provides abstraction between the hardware
and the rest of the stack, responsible for
device drivers (Camera , Wi Fi, etc…),
resources management , power management,
security and net working.
• There are many good reasons for choosing
Linux as the base of the Android stack. Some
of the main ones are portability, security, and
features.
C/C++ Libraries(native libraries)
• Native libraries are C/C++ libraries often taken from the open source
community in order to provide necessary services to Android application
layer. They include:
• WebKit: a fast web rendering engine used by Safari, Chrome, and other
browsers
• SQLite: a full-featured SQL database
• Apache Harmony: an open source implementation of Java
• OpenGL: 3D graphics libraries
• OpenSSL: the secure socket layer
• and many others
• While many of these libraries are taken as-is, one notable exception is
Bionic. Bionic is basically a rewritten version of Standard C Library. The
reason for Bionic is two fold:
Technology: to make it purpose-built for tiny battery powered devices
License: to make it license-friendly to others who may want to adopt it and
change it
The Android Runtime
• includes Core libraries and the Dalvik Vitual
Machine.The Core libraries provide most of
java libraries + additional Android libraries.
The Dalvik VM provides (Just In Time) JIT
compilation. the VM is optimized to run
multiple instances of VMs. As Java
applications access the core libraries each
application has its own VM
The Android Application Framework
• Provides classes required to develop an
Android application and abstraction between
hardware access. the Android Java API’s main
library include telephony, content providers
(data), resources, locations and UI.
App frmework(continued)
• The application framework is a rich environment that provides
numerous services to you, the app developer,. This is the part of
the platform that is best documented and extensively covered.
That is because it is this layer that enables the mass-market of
developers to get creative and be empowered to create fantastic
applications.
• In application framework layer, you will find numerous Java
libraries specifically built for Android. You will also find many
services (or managers) that provide the ecosystem of capabilities
your application can tap into, such as location, sensors, WiFi,
telephony and so on
• As you explore the Android application development, most of
your focus will be on this part of the stack. You will get to use
many of the application framework components yourself.
Application Layer
• all Android applications(native or third party)
are built on the application layer using the
same API.
• So Android applications are written in Java,
but remember it is not Java ME (Mobile
Edition). It’s just Most of J2SE libraries +
Android’s own Java libraries.
Android Application Architecture
Android Application Architecture
• Android architecture encourages component
reuse allowing you to publish and share
activities, services and data between
applications with security restrictions defined
by you. This enables developers to include out
of the box components such as the phone
dialer or contact manager to their
applications, or add new functionalities to
them.
Application Architecture
• Activity Manager: which controls the life cycle
of the activities, activities can be compared to
the windows or web forms they carry the
controls (views) that construct the interface,
an activity represents a single screen.
Application Architecture
• Views: the UI components that construct the
interface. They can be compared to the swing or
windows forms controls
• Notification Manger: provides a consistent
mechanism to notify or alert users.
• Content Providers: lets applications to share data
between them.
• Resources Manager: much like the ASP.NET
resources concept. Enables the developer to
store resources such as strings or images.
Secutiy and permissions
• During deployment on an Android device, the
Android system will create a unique user and
group ID for every Android application. Each
application file is private to this generated user,
e.g. other applications cannot access these files.
• In addition each Android application will be
started in its own process.
• Therefore by means of the underlying Linux
operating system, every Android application is
isolated from other running applications. A
misbehaving application cannot easily harm
other Android applications.
Android Applications Security
Security and permissions
• If data should be shared the application must do this
explicitly, e.g. via a Service or a ContentProvider.
• Android also contains a permission system. Android
predefines permissions for certain tasks but every
application can also define its own permissions.
• An application must declare in its configuration file
(AndroidManifest.xml) that it requires certain
permissions.
• Depending on the details of the defined permission,
the Android system will during installation either
automatically grant the permission, reject it or ask the
user if he grants these permissions to the application.
Security and permissions
• If for example the application declares that is requires
Internet access then the user need to confirm this during
installation.
• This is called "user driven security". The user decides to
grant a permission or to deny it. If the user does not want to
give all permissions required by the application, this
application cannot be installed. The check of the permission
is only performed during installation, permissions cannot be
denied or granted after the installation.
• Typically not all users check the permissions in detail but
some users do and if there is something strange with them,
they will write bad reviews on the corresponding Android
markets.
Android Application Component
Important Android Compnents(Activity)1
• Activity represents the presentation layer of
an Android application. A simplified (and
slightly incorrect) description is that an
Activity is a a screen which the user sees.. An
Android application can have several activities
and it can be switched between them during
runtime of the application.
Important android components
• Views are user interface widgets, e.g.
buttons or text fields. The base class for all
Views is android.view.View. The layout of the
Views is managed by subclasses of type
android.view.ViewGroups. Views often have
attributes which can be used to change their
appearance and behavior.
Important android compnents(services)
• Services perform background tasks without
providing an UI. They can notify the user via
the notification framework in Android.
Important android
compnents(ContentProvider)
• ContentProvider provides an structured
interface to data. Via a ContentProvider your
application can share data with other
applications. Android contains an SQLite
database which is frequently used in
conjunction with a ContentProvider to persists
the data of the ContentProvider.
Important android compnents(Intents
• Intents
are asynchronous messages which allow
the application to request functionality from other
components of the Android systen, e.g. from Services
or Activities. An application can call a component
directly (explicit intent) or ask the Android system to
evaluate registered components for a certain Intents
(implicit intents). For example the application could
implement sharing of data via an Intent and all
components which allow sharing of data would be
available for the user to select. Applications register
themselves to an intent via an IntentFilter. Intents
allow to combine loosely coupled components to
perform certain tasks.
Important android
compnents(BroadcastReceiver)
• BroadcastReceiver can be registered to
receives system messages and Intents.
BroadcastReceiver will get notified by the
Android system if the specified situation
happens. For example a BroadcastReceiver
could get called once the system completed its
boot process or if a phone call is received.
Important android compnents(widgets)
• Widgets are interactive components which are
primary used on the Android homescreen. They
typically display some kind of data and allow the
user to perform actions via them. For example a
Widget could display a short summary of new
emails and if the user select a email it could start
the email application with the selected email