Upload
harshad-lokhande
View
941
Download
1
Embed Size (px)
Citation preview
23 Sept 2013Harshad Lokhande
Android OS
Contents
Contents
4. Advanced Domains
Services Audio & Video Camera & Sensors Future Scopes
3. Beyond Basics
Telephony & SMS Data Storage Concepts Content Provider Network Services
2. Application Concepts
Application Structure Understanding Manifest Working with Activities Intents
1. Basics
Introduction History OS Architecture Components
Android OS
Contents - Basics
Basics •Mobility OS•Market SharesIntroduction
•How invented?•Acquired by Google•What's new?•First Open Source Mobile Platform
History
•Graphical View•Concepts•JAVA & DVM ConceptsOS
Architecture
•Activity•Service•Broadcast Reciever•Content Provider
Components
1
Android OS
Introduction
Contents – Basics
Mobility OS• A mobile operating system (OS) is a software that
allows smart phones, tablet PCs and other devices to run applications and programs.
• Coding in low-level C or C++, have needed to understand the specific hardware they were coding for, typically a single device
• Platforms like Microsoft’s Windows Phone and the Apple iPhone also provide a richer, simplified development environment for mobile applications
Android OS
Contents – Basics - Introduction
Market Shares
Worldwide Mobile’s Market Share Analysis Comparison between Features of Different Mobile OS
History
Contents – Basics
How Invented ?• Android Inc. was founded in Palo Alto, California in October, 2003 by
Andy Rubin, Rich Miner, Nick Sears, and Chris White.• It was a college project.
Acquired By Google
• Google acquired Android Inc. in August, 2005• On October 21st, 2008, Android 1.0 became available to the public
Android OS
First Mobile with Android 1.0
Contents – Basics - History
What’s New ?• Android is the first complete, open, and
free mobile platform.,• low-level interface with the hardware,
memory management, and process control, all optimized for mobile and embedded devices
First Open Source Mobile Platform
• Android is open source and Google releases the code under the Apache License
Android OS
OHA Systems
Android Releases…..!!
OS Architecture
Contents – Basics
Graphical View & Concepts• The key layers and components that make up the
Android open source software stack
Android OS
•Linux provides the hardware abstraction layer for Android
Contents – Basics – OS Architecture
JAVA & DVM Concepts
Android OS
Different executions based on Type Building Block of App Execution
Components
Contents – Basics
Activity & Services• An activity is a user interface screen• An intent is a mechanism for describing a specific
action, such as “pick a photo,” “phone home,” or “open the pod bay doors.
• A service is a task that runs in the background without the user’s direct interaction
Broadcast Receiver & Content Provider• A content provider is a set of data wrapped up in a
custom API to read and write it.• Broadcast Receivers enable your application to
listen for Intents that match the criteria you specify in real-time
Components Android OS
Android Introduction
Application Concepts
•Exploring Project Application Structure•Building BlocksApplication
Structure
•Closer look•Editing inside•Drawables , Resources & LayoutsUnderstanding
Manifest
•What’s Activity?•Life Cycle•Activity Callbacks
Activities
•Introduction •Explicit Intents•Implicit Intents•Returning Result Based Intents
Intents
Contents – Application Concepts
2
Android OS
App Structure
Contents – Application Concepts
Exploring Project Application Structure• The folder structure of application is as shown in image.
code
images
files
UI layouts
constants
Autogenerated resource list
Application Structure
Formation of executable file “.apk”
Android OS
Contents – Application Concepts – App Structure
Building Blocks
Different components of GUI
• Following are different components required to build an application.
Android OS
Understanding Manifest
Contents – Application Concepts
Closer look
The following XML snippet shows a typical manifest node:<manifest xmlns:android=”http://schemas.android.com/apk/res/android”package=“com.demo.myapp“android:versionCode=“1“android:versionName=“0.9 Beta“android:installLocation=“preferExternal“>[ ... manifest nodes ... ]</manifest>
Importance of Manifest File Actual View of Setting Manifest File Android OS
Contents – Application Concepts – Understanding Manifest
Editing inside
• Each of the next three tabs contains a visual interface for managing the application, security, and instrumentation (testing) settings
Drawables , Resources & Layouts
• Can edit Simple Values, Strings , Colors, Dimensions , Text Fonts , Size ,Names , etc
Types of Layout Resource Structure Android OS
Activities
Contents – Application Concepts
What’s Activity? • Each Activity represents a screen that an
application can present to its users• Applications can define one or more activities
to handle different phases of the program
Life Cycle of Activity
Life Cycle & Activity Callbacks
• Android applications do not control their own process lifetimes
• Run time handles the termination and management of an Activity’s process
• The Activity class has a number of callbacks that provide an opportunity for an activity to respond to events such as suspending and resuming.
Android OS
Intents
Contents – Application Concepts
Introduction• Intents are used as a message-passing
mechanism that works both within your application and between applications.
• Intents are also used to broadcast messages across the system.
Explicit Intents & Explicit Intents• Use for Intents is to start new Activities,
either explicitly (by specifying the class to load) or implicitly (by requesting that an action be performed on a piece of data).
Example of Implicit Intent
Android OS
Contents – Application Concepts - Intents
Returning Result Based Intents
• An Activity started via startActivity is independent of its parent and will not provide any feedback when it closes.
• Where feedback is required, you can start an Activity as a sub-Activity that can pass results back to its parent.
• When a sub-Activity is finished, it triggers the onActivityResult event handler within the calling Activity.
• Native Actions are like ACTION_CALL , ACTION_DIAL , ACTION_PICK , ACTION_WEB_SEARCH ,etc.Code Snippet of Intent
Android OS
Android Introduction
Beyond Basics •Hardware Requirement
•Initiating Phone Calls•Monitoring Changes•Sending SMS & MMS
Telephony & SMS
•Introducing Android Database •SQLite Database•Values and CursorsData Storage
Concepts
•Interface with Data Sources•Content Resolver •Querying
Content Provider
•Introducing Connectivity Manager•Monitoring Network Connectivity•Bluetooth & WIFI•Using Internet Services
Network Services
Contents – Beyond Basics
3
Android OS
Telephony & SMS
Contents – Beyond Basics
Hardware Requirement
• Some applications don’t make sense on devices that don’t have telephony support
Initiating Phone Calls• Below code starts a dialer Activity
that should be pre-populated with the number you specified
• Android telephony architecture is split between java and native code.
How to call number:Intent intent = new Intent(Intent.ACTION_CALL,
Uri.parse("tel:502310109")); startActivity(intent);
Permission:• android.permission.CALL_PHONE Telephony Manager
Android OS
Contents – Beyond Basics - Telephony & SMS
Monitoring Changes• Can monitor Telephony changes in real-time.• Activity.RESULT_OK• SmsManager.RESULT_ERROR_GENERIC_FAILU
RE• PhoneStateListener.LISTEN_CALL_STATE • PhoneStateListener.LISTEN_CELL_LOCATION • PhoneStateListener.LISTEN_DATA_ACTIVITY
Sending SMS & MMS• Android provides support for
sending both SMS and MMS• But Android API does not include
simple support for creating MMS
Code Snippet of SMS Manager
Code Snippet of MMS Manager
Android OS
Data Storage Concepts
Contents – Beyond Basics
Introducing Android Database • Android provides structured data persistence through a
combination of SQLite databases and Content Providers.• Every application can create its own databases over which
it has complete control
SQLite Database• Used to store application data using a managed, structured approach• SQLite is a well-regarded relational database management system (RDBMS). It is:
• Open-source , Standards-compliant , Lightweight , Single-tier• SQLiteOpenHelper is an abstract class used to implement the best
practice pattern for creating, opening, and upgrading databases.
DB file in Project
Values and Cursors• Content Values are used to insert new rows into tables• The Cursor class includes a number of navigation functions :
• moveToFirst , moveToPrevious• getColumnNames , getPosition
Android OS
Content Provider
Contents – Beyond Basics
Interface with Data Sources• Content Providers can be shared
between applications, queried for results, have their existing records updated or deleted, and have new records added.
Content Provider
Content Resolver • Each application includes a
ContentResolver instance, accessible using the getContentResolver method, as follows:
• ContentResolver cr = getContentResolver();
• Content Resolvers are the corresponding class used to query and perform transactions on those Content Providers.
Querying• Query results are returned as Cursors
over a resultAndroid
OS
Network Services
Contents – Beyond Basics
Introducing Connectivity Manager• With the speed, reliability, and cost of
Internet connectivity being dependent on the network technology used (Wi-Fi, GPRS, 3G, LTE, and so on).
• Android networking is principally handled via the ConnectivityManager
Monitoring Network Connectivity• The Connectivity Manager provides a high-
level view of the available network connections
• To monitor network connectivity, create a Broadcast Receiver that listens for : ConnectivityManager.CONNECTIVITY_ACTION Broadcast Intents,Supporting Platforms of Communication
NFC
Android OS
Contents – Beyond Basics - Network Services
Bluetooth & WIFI
• Bluetooth is a communications protocol designed for short-range, low-bandwidth peer-to-peer communications.
• Bluetooth device is controlled via the BluetoothAdapter class
• To modify any of the local device properties, the BLUETOOTH_ADMIN permission is also required
• We manage the current Wi-Fi connection, scan for access points, and monitor changes in Wi-Fi connectivity by using WIFIManager class
• Wi-Fi Direct is a communications protocol designed for medium-range, high-bandwidth peer-to-peer communications
Bluetooth Comm. Layer Interface
Android OS
Android Introduction
Advanced Domains •Introducing Services
•Service Life Cycle•Background Threads•Using Alarms
Services
•Data Types accessible by Android •Playing Audio & Video•Introducing Media Player & Media Effects
Audio & Video
•Taking Images from Camera Using Intents•Controlling Camera Parameters•Other Sensors like Ambient Light , Gyroscope , Accelerometer , etcCamera &
Sensors
•Google Gadgets•Security•Introduction to ADK & NDK•Augmented •In App Billing
Future Scopes
Contents – Advanced Domains
4
Android OS
Services
Contents – Advanced Domains
Introducing Services
• Unlike Activities, which display graphical interfaces, Services run invisibly — doing Internet lookups, processing data, updating your Content Providers, firing Intents, and triggering Notifications
• Services are started, stopped, and controlled from other application components, including Activities, Broadcast Receivers, and other Services.
Service Life Cycle• The diagram on the left shows the lifecycle
when the service is created with startService() and the diagram on the right shows the lifecycle when the service is created with bindService()
Android OS
Contents – Advanced Domains - Services
Background Threads
• Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC)
• Alternatively, the AsyncTask class lets you define an operation to be performed in the background and provides event handlers that enable you to monitor progress and post the results on the GUI Thread
Using Alarms
• Alarms are a means of firing Intents at predetermined times or intervals.
• Alarms that fire broadcast Intents, start Services, or even open Activities, without your application needing to be open or running
Alarm App Activity Android OS
Audio & Video
Contents – Advanced Domains
Playing Audio & Video• Android API’s are capable of playing and
recording a wide range of image, audio, and video formats, both locally and streamed.
Data Types accessible by Android• Android 4.0.3 (API level 15) supports the
following multimedia formats for playback as part of the base framework.
AV Formats
Audio Player Sample
Video Player Sample Android OS
Contents – Advanced Domains - Audio & Video
Introducing Media Player & Media Effects• Android 2.3 (API level 9) introduced a suite of audio
effects that can be applied to the audio output of any Audio Track or Media Player.
• Android 4.0.3, the following five AudioEffect subclasses :• Equalizer , Virtualizer , BassBoost , PresetReverb ,
EnvironmentalReverb
Audio Framework Video Framework Android OS
Camera & Sensors
Contents – Advanced Domains
Taking Images using Intents• The easiest way to take a picture from within your
application is to fire an Intent using the• MediaStore.ACTION_IMAGE_CAPTURE action:
startActivityForResult( new Intent(MediaStore.ACTION_IMAGE_CAPTURE), TAKE_PICTURE);
• This launches a Camera application providing your users with the full suite of camera functionality without you having to rewrite the native Camera application.Controlling Camera Parameters• To access the camera hardware directly, you
need to add the CAMERA permission to your application manifest:• <uses-permission
android:name=”android.permission.CAMERA”/>• Camera settings are stored using a
Camera.Parameters object, accessible by calling the getParameters method on the Camera object
Android OS
:[get/set]SceneMode:[get/set]FlashMode:[get/set]WhiteBalance:[get/set]AutoWhiteBalanceLock:[get/set]FocusMode
Camera Parameter API’s
Contents – Advanced Domains - Camera & Sensors
Other Sensors• Android supports many other
types of sensors like , Accelerometer , Gyroscope , Magnetometer , Ambient Light Sensor , Ambient Temp. Sensor , etc.
• To identify the sensors that are on a device you first need to get a reference to the sensor service.
• To monitor raw sensor data you need to implement two callback methods that are exposed through theSensorEventListener interface: onAccuracyChanged() and onSensorChanged()
Android OSHow to check
Sensor ?
List of available sensors
Future Scopes
Contents – Advanced Domains
Google Gadgets• Google Glass is a wearable computer
with an optical head-mounted display (OHMD) that is being developed by Google in the Project Glass research and development project
• The main way to operate the glasses is through voice commands, and by tilting your head.
Android OS
Contents – Advanced Domains – Future Scopes
Introduction to ADK & NDK• The Accessory Development Kit (ADK) is a reference
implementation for hardware manufacturers and hobbyists to use as a starting point for building accessories for Android
• The ADK 2012 is based on the Arduino open source electronics prototyping platform, with some hardware and software extensions that allow it to communicate with Android devices
• The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++.
• The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin) platforms.
In App Billing• In-App Billing (IAB) is a Google Play service that
can be used as an alternative to charging up-front for an application
• IAB has proven to be a powerful new monetization option for application developers
Android OS
Security• Each Android package has a unique
Linux user ID assigned to it during installation. This has the effect of sandboxing the process and the resources it creates, so that it can’t affect (or be affected by) other applications.
Augmented Reality
• Augmented Reality is the virtual technique , by which 3D images , maps , etc can be visualized by spotting camera on special codes.
Thank you