andbook - Android Programming
2
powered by anddev.org
Content
Foreword / How to read this doc ................................................. 5
Introduction................................................................................ 6
What is Android – a GPhone? ...................................................... 7
Android from above ........................................................................ 8
Openness ....................................................................................................... 8
All applications are created equal ................................................................. 9
Breaking down application boundaries ......................................................... 9
Fast & easy application development ........................................................... 9
The first weeks .............................................................................. 12
Dalvik.equals(Java) == false ........................................................... 13
Differences to a normal JavaVM ................................................................. 13
The Android Code Challenge ..................................................... 14
Creating Android Applications .................................................. 15
Anatomy of an Android Application ............................................... 15
Activity ......................................................................................................... 15
Intent Receiver ............................................................................................ 17
Service ......................................................................................................... 17
Content Provider ......................................................................................... 18
Android User Interfaces ................................................................. 19
Hierarchy of Screen Elements ..................................................................... 19
Comparing Android UI Elements to Swing UI Elements .............................. 22
The AndroidManifest.xml ......................................................... 23
General ......................................................................................... 24
<manifest> ................................................................................................... 25
<uses-permission> ....................................................................................... 25
<permission> ............................................................................................... 25
<instrumentation> ....................................................................................... 25
<application> ............................................................................................... 25
andbook - Android Programming
3
powered by anddev.org
<meta-data> ................................................................................................ 27
<receiver> .................................................................................................... 27
<service> ...................................................................................................... 27
<provider> ................................................................................................... 28
Resources and the magic R.java ................................................ 29
Resources ..................................................................................... 29
List of resources ........................................................................................... 29
Using resources in code ............................................................................... 30
Referencing Resources ................................................................................ 31
Alternate Resources & Localization ................................................ 32
The magic R.java ........................................................................... 33
Hello World – The Android way. ................................................ 34
Installing the Android SDK ............................................................. 35
The Android Development Tools (ADT) ....................................................... 35
Installation done, let’s do some code ............................................. 37
Creating a new Android Project .................................................................. 37
Running your first application ..................................................................... 43
UIs the Java way ........................................................................... 45
System.out.println(…) ? ................................................................. 46
The LogCat ................................................................................................... 46
Using Intents ............................................................................ 49
Starting (Sub)Activities .................................................................. 49
Finding XML-defined Views in Java-Code .................................................... 52
Handling Clicks to Views .............................................................................. 53
Returning values from SubActivities ........................................................... 56
Passing Data to (Sub)Activities ...................................................... 58
Important Layouts and ViewGroups .......................................... 60
The RelativeLayout ........................................................................ 60
andbook - Android Programming
4
powered by anddev.org
Bibliography ............................................................................. 61
Lost chapters ............................................................................ 62
The communities .......................................................................... 62
andbook - Android Programming
5
powered by anddev.org
Foreword / How to read this doc
This document was written for developers who have worked with Java™
before and want to start developing for the Android Platform. I tried to
make this as much “hands on” as possible, placing example codes
everywhere it fit. Also I tried to insert as many picture as possible,
because they liven up the learning process and relax the reader’s eyes.
But unfortunately coding is not everything; one has to learn about
some basic facts of the Android Platform to fully understand. That is
what is described on the first ~XXX pages. It is not necessary to read all
those describing pages, but it is preferable. You could decide to treat it as
a kind of reference. What you would read there is also explained when it
occurs during the “hands on”-process. So you could directly start at Hello
World – The Android Way.
All codes you see in this document (the whole workspace) will be
available on:
http://andbook.anddev.org/sources/
Have fun reading…
评论0
最新资源