2. Agenda
• Android
History
• Android
and
Java
• Android
SDK
• Hello
World!
• Main
Building
Blocks
• Debugging
• Summary
3. History
2005
Google
buys
Android,
Inc.
Work
on
Dalvik
starts
2007
OHA
Announced
Early
SDK
2008
G1
Announced
SDK
1.0
Released
2009
G2
Released
Cupcake,
Donut,
Eclair
4. Android
and
Java
Android Java =
Java SE –
AWT/Swing +
Android API
5. Android
SDK
-‐
What’s
in
the
box
SDK
Tools
Docs
Platforms
Data
Skins
Images
Samples
Add-ons
Google Maps
6. The
Tools
Tools are important part of the
SDK. They are available via
Eclipse plugin as well as command
line shell.
8. Create
New
Project
Use the Eclipse tool to create a new
Android project.
Here are some key constructs:
Project
Eclipse
construct
Target
minimum
to
run
App
name
whatever
Package
Java
package
AcXvity
Java
class
11. The
Java
File
package com.marakana;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
14. AcXviXes
Activity is to an Android Application
application what a Main Activity
Another Another
Activity Activity
web page is to a
website. Sort of.
15. AcXvity
Lifecycle
Starting
Activities have a well-
(1) onCreate()
(2) onStart()
(3) onRestoreInstanceState()
defined lifecycle. The (4) onResume()
Android OS manages
your activity by Running
changing its state. (3) onResume()
(2) onStart()
(1) onSaveInstanceState()
(2) onPause()
You fill in the blanks.
(1) onRestart() onResume()
(1) onSaveInstanceState()
Stopped (2) onStop() Paused
onDestroy()
or <process killed>
<process killed>
Destroyed
16. Intents
Intents are to Android Application
Android apps Another
Main Activity Intent
what hyperlinks Activity
are to websites.
They can be
Intent
implicit and
Android Application
explicit. Sort of
like absolute and Main Activity Intent
Another
Activity
relative links.
17. Services
A service is something that can be started and
stopped. It doesn’t have UI. It is typically managed
by an activity. Music player,
for example
18. Service
Lifecycle
Service also has a Starting
lifecycle, but it’s (1) onCreate()
much simpler than (2) onStart()
activity’s. An activity onStart()
typically starts and
stops a service to do Stopped Running
some work for it in
the background. onStop()
Such as play music,
check for new onDestroy()
or
tweets, etc.
<process killed>
Destroyed
19. Content
Providers
Content Providers share Content
content with applications Provider
across application Content URI
boundaries. insert()
Examples of built-in update()
Content Providers are: delete()
Contacts, MediaStore, query()
Settings and more.
20. Broadcast
Receivers
An Intent-based publish-subscribe mechanism. Great for listening
system events such as SMS messages.
22. LogCat
The universal, most
versatile way to track
what is going on in
your app.
Can be viewed via
command line or
Eclipse.
Logs can be
generated both from
SDK Java code, or
low-level C code via
Bionic libc extension.
23. Debugger
Your standard debugger is included in SDK, with all the usual bells & whistles.
24. TraceView
TraceView helps you profile you application and find bottlenecks. It shows
execution of various calls through the entire stack. You can zoom into specific
calls.
25. Hierarchy
Viewer
Hierarchy Viewer helps
you analyze your User
Interface.
Base UI tends to be the
most “expensive” part of
your application, this tool
is very useful.
26. Summary
Android is based on Java.
You write Java code, but technically
don’t run it.
Java is augmented with XML, mostly
for UI purposes.
Android Java is mostly based on Java
SE with replacement UI libraries.
Marko Gargenta, Marakana.com
marko@marakana.com
+1-415-647-7000
Licensed under Creative Commons
License (cc-by-nc-nd). Please Share!