Android101 - Intro and Basics
-
Upload
jromero1214 -
Category
Technology
-
view
123 -
download
0
Transcript of Android101 - Intro and Basics
Android 101Part 1. Introduction, basics,
and your environment
While we wait…
Android ADT Bundle
http://developer.android.com/sdk/index.ht
ml
Genymotion
http://www.genymotion.com/
Prerequisites
OOP Language Experience
Computer (Mac/Linux/Windows)
Plus:
Java – programming
XML – layouts and resources
Command Line – general commands
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
Source: http://www.armdesigner.com/NewsLook617.html
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
…
Uses for Android?
Calls
Music
Videos
Games
Social
…
Educational
Commercial (POS)
Satellite
Security
Accessory
…
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
Versions (OS vs API)
ComponentsIn context of our demo
application
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
Step 1: DisplayWe need to display a few screens to the user…
Activities
Represents a single screen
extends Activity class
Fragments
Represents a section of the screen
An Activity coordinates the Fragment(s)
Fragments can be reused
extends Fragment class
Step 2: Persist DataWe need to persist the notes the user adds…
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
Step 3: Record/Play
AudioWe need to record or play audio while allowing for
multitasking…
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
Step 4: Phone stateWe need to stop/pause audio playback or
recording…
BroadcastRecievers
Listens to system-wide events
Incoming SMS
Alarm
Network State
…
Usually triggers a larger action
extends BroadcastReciever class
Using the
Components
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>
…
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
IntentFilters action
name android.intent.action.SEND
com.example.whatever.DO_IT
data mimeType scheme host port path …
category BROWSABLE LAUNCHER DEFAULT
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
ResourcesA very quick glimpse
Resources
animator
anim
color
drawable
layout
menu raw
values arrays
colors dimens strings styles
xml
res/ directory
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
EnvironmentSetting it up
Environment - Java JDK
Java 7 JDK - http://goo.gl/zXjC
To confirm:
… run: javac –version
… output: javac 1.7.0_45
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