android101 - intro and basics
TRANSCRIPT
![Page 1: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/1.jpg)
Android 101Part 1. Introduction, basics,
and your environment
![Page 2: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/2.jpg)
While we wait…
Android ADT Bundle
http://developer.android.com/sdk/index.ht
ml
Genymotion
http://www.genymotion.com/
![Page 3: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/3.jpg)
Prerequisites
OOP Language Experience
Computer (Mac/Linux/Windows)
Plus:
Java – programming
XML – layouts and resources
Command Line – general commands
![Page 4: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/4.jpg)
What is Android?
Platform
The operating system
Framework
Set of APIs to develop for the platform
SDK
Set of tools (including the framework) to
assist developing for the platform
![Page 5: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/5.jpg)
Source: http://www.armdesigner.com/NewsLook617.html
![Page 6: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/6.jpg)
Android and Google
Android is open source (AOSP)
Google is the owner/maintainer
Source: http://source.android.com
GApps
Google specific closed source apps
Google Play Store
Google Play Services
Google Maps
…
![Page 7: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/7.jpg)
Uses for Android?
Calls
Music
Videos
Games
Social
…
Educational
Commercial (POS)
Satellite
Security
Accessory
…
![Page 8: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/8.jpg)
Android vs iOS
Open Source
Java / XML
78.4% MS Worldwide
50.6% MS USA
$100-$200/month
800,000 apps
~$130,000 senior dev
Closed Source
Objective-C
17.6% MS Worldwide
43.9% MS USA
$500-$1000/month
800,000 apps
~$120,000 senior dev
![Page 9: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/9.jpg)
Versions (OS vs API)
![Page 10: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/10.jpg)
ComponentsIn context of our demo
application
![Page 11: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/11.jpg)
Demo Application
Features:
Displays lists of saved notes
Allows user to add and edit notes
Can record notes
Can playback notes
Stops recording or playback when a call is
incoming or made
![Page 12: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/12.jpg)
Step 1: DisplayWe need to display a few screens to the user…
![Page 13: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/13.jpg)
Activities
Represents a single screen
extends Activity class
![Page 14: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/14.jpg)
Fragments
Represents a section of the screen
An Activity coordinates the Fragment(s)
Fragments can be reused
extends Fragment class
![Page 15: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/15.jpg)
Step 2: Persist DataWe need to persist the notes the user adds…
![Page 16: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/16.jpg)
ContentProvider
Manages data
Can use almost any storage option
SQLite
File
Remote Server
…
Provides consistent interface (CRUD)
Can be restricted with permissions
extends ContentProvider class
![Page 17: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/17.jpg)
Step 3: Record/Play
AudioWe need to record or play audio while allowing for
multitasking…
![Page 18: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/18.jpg)
Services
Used to perform in the background
Service class works in main thread
IntentService (child class) works in
background thread
Background = No user interface
extends Service class
![Page 19: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/19.jpg)
Step 4: Phone stateWe need to stop/pause audio playback or
recording…
![Page 20: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/20.jpg)
BroadcastRecievers
Listens to system-wide events
Incoming SMS
Alarm
Network State
…
Usually triggers a larger action
extends BroadcastReciever class
![Page 21: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/21.jpg)
Using the
Components
![Page 22: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/22.jpg)
AndroidManifest.xml Declares: Permissions used
Libraries required
Hardware required
Package name (must be unique)
Application name
Components Activity <activity>
Service <service> ContentProvider <provider> BroadcastReciever <reciever>
…
![Page 23: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/23.jpg)
Intents (options) Component Name
The name of the component to start
Action Examples: VIEW, EDIT, PICK
Data Uri to the data
Examples: Image, URL, Document
Category Examples: Browsable, Launcher
Extras Key-value pairs of data to pass to the component
Flags Used to tell the Android system how to launch certain
components
extends Intent class
![Page 24: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/24.jpg)
IntentFilters action
name android.intent.action.SEND
com.example.whatever.DO_IT
data mimeType scheme host port path …
category BROWSABLE LAUNCHER DEFAULT
![Page 25: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/25.jpg)
Intents Explicit Intent
Intent to start a specific component you know exists, such as from your app or a system component
new Intent(this, SecondActivity.class)
Implicit Intent
Intent to do a general action and possibly allow other applications to handle it
new Intent(Intent.ACTION_VIEW,
Uri.parse(“http://google.com”))
extends Intent class
![Page 26: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/26.jpg)
ResourcesA very quick glimpse
![Page 27: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/27.jpg)
Resources
animator
anim
color
drawable
layout
menu raw
values arrays
colors dimens strings styles
xml
res/ directory
![Page 28: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/28.jpg)
Resources (qualifiers)
Language and region
Layout direction Smallest Width Available Width Available Height Screen size Screen Aspect
Screen Orientation UI Mode Screen Pixel Density Platform Version …
res/ directory
![Page 29: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/29.jpg)
EnvironmentSetting it up
![Page 30: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/30.jpg)
Environment - Java JDK
Java 7 JDK - http://goo.gl/zXjC
To confirm:
… run: javac –version
… output: javac 1.7.0_45
![Page 31: Android101 - Intro and Basics](https://reader035.vdocuments.net/reader035/viewer/2022062419/55a19cd81a28ab114e8b45e2/html5/thumbnails/31.jpg)
Environment - ADT Bundle
ADT Bundle - http://goo.gl/2qpr
Eclipse + ADT Plugin
Android SDK Tools
Android Platform Tools
Latest Android platform
Latest Android System image