1. February 19, 2011 @ De La Salle University - Dasmariñas
Part 2: Android Application Development 101
Mike Rivera - Señior Android Developer @ Excitor Asia
2. All about Android Development
✤ First things first
✤ Android Application Components
✤ User Interface
✤ Application Resources
✤ AndroidManifest.xml
✤ How to create Android Apps?
✤ How to Publish Android Applications?
3. February 19, 2011 @ De La Salle University - Dasmariñas
First things first
Tools you need to learn and understand.
5. Java SDK
Go To >
http://www.oracle.com/technetwork/java/javase/downloads
Download Java Development Kit (JDK) 6 Update 22(or higher)
Install JDK to your local drive (remember the location)
6. Simply learn basic Java!
✤ Read about their Variables
✤ Operators
✤ Expressions, Statements and Blocks
✤ Control Flow Statements
You’re set and ready to go on with Android
Programming !
7. Want to learn more about Java?
✤ If you still have the urge read on OOP
more.
✤ Understand their Classes and Objects
✤ Don’t forget Interfaces and Inheritance
If time permits, understand them (YOU should!)
8. Eclipse IDE
Go To > http://eclipse.org/downloads/
Download Eclipse IDE for Java Developers (32 bit or 64 bit)
Unzip the file to your desired location
Look for the Eclipse Icon and click it to start.
Select your Operating System (Mac,Windows or Linux)
9. Android SDK
Download and Install the SDK Starter Package
Select a starter package from the Android Developer Site and download it to your
development computer. To install the SDK, simply unpack the starter package to a safe
location and then add the location to your PATH.
If you are developing in Eclipse, set up a remote update site at
https://dl-ssl.google.com/android/eclipse/. Install the Android
Development Tools (ADT) Plugin, restart Eclipse, and set the "Android" preferences in
Eclipse to point to the SDK install location.
Install the ADT Plugin for Eclipse
Use the Android SDK and AVD Manager, included in the SDK starter package, to add
one or more Android platforms (for example, Android 1.6 or Android 2.2) and other
components to your SDK
Add Android platforms and other components to your SDK
11. Activities
✤ Presentation Layer of the
Application you are
building
✤ For each screen you need
a matching Activity
✤ An Activity uses Views to
build the User Interfaces
✤ Represents a screen or
window. Sort of.
12. Intents
✤ Represents events or
actions
✤ They are to Android Apps
what hyperlinks are to
websites. Sort of.
✤ Holds content of the
message
✤ Can be implicit or explicit.
13. Services
✤ Represents events or
actions
✤ Do not interact with the
users.
✤ Can update your data
sources and Activities,
and trigger specific
notifications.
14. ContentProviders
✤ Manage and share
application across
application boundaries
✤ Data can be stored in the
file system, in an SQLite
database, or in any other
manner that makes sense.
✤ Ex. of built-in content
providers: Contacts &
MediaStore.
15. BroadcastReceivers
✤ Listen for broadcast
Intents that match some
defined filter criteria
✤ Can automatically start
your application as a
response to an intent.
✤ Intent-based published
subscribe mechanism.
Listens for system events
like SMS.
16. User Interfaces
✤ There are two UI approaches: procedural and declarative (xml code)
✤ You can mix both approaches.
17. User Interfaces
Best Practice
✤ Start with XML (declarative), and create most of the UI’s.
✤ Switch to Java and implement the UI logic by hooking up the control
Id.
From your xml layout code:
<ListView
android:id="@+id/myListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
From your Activity class code:
ListView myListView =
(ListView)findViewById(R.id.myListView);
Procedural code:
ListView myListView = new ListView(this);
setContentView(myTextView);
19. UI: Views
✤ Basic UI Component
✤ A.k.a Widgets / Control
✤ Responsible for drawing and event-
handling.
✤ Android UI includes many modern
UI’s widgets and composite ones such
as Buttons, Tabs, ListViews,
ProgressBar, Time and Date Pickers
etc.
20. UI: ViewGroups
✤ A.k.a Layouts
✤ Most common way to define your
layout and express the view
hierarchy is with an XML layout
file
✤ Using more and different kinds of
view groups, you can structure
child views and view groups in an
infinite number of ways.
LinearLayout: one of the
most commonly used
layout
21. UI: Dialogs and Menus
Dialogs
a small window that appears in front of the current Activity
(Alert,Progress,DatePicker, TimePicker and a custom one)
Menus
Concerned about having to much functionality on the screen => use
menus
22. Application Resources
External files (that are, non-code files) that are used by your code and
compiled into your application at build time. Android supports a
number of different kinds of resource files, including XML, PNG, and
JPEG files.
At compile time, Android generates a class named R that contains resource identifiers to all the resources in your
program. This class contains several subclasses, one for each type of resource supported by Android, and for which
you provided a resource file.
• res/anim - XML files for animations
• res/drawable – image files
• res/layout – XML files for screen layouts
• res/values – XML files that can be compiled into many kinds of
resources
• res/xml – Arbitrary XML files that are compiled and can be read
at run time.
• res/raw – Arbitrary files to copy directly to the device
23. AndroidManifest.xml
✤ It describes the components of the application — the activities,
services, broadcast receivers, and content providers that the
application is composed of.
✤ It declares which permissions the application must have in order to
access protected parts of the API and interact with other
applications.
✤ It declares the minimum level of the Android API that the
application requires.
✤ It lists the libraries that the application must be linked against.
Remember this is the most important file & these are just some
of the things it can do.
25. How to create Android Apps?
✤ All our tools are set (right?)
✤ We create an AVD (Android Virtual Device)
✤ Create New Android Project
✤ Construct the UI (either in java or xml)
✤ Do our logic in Java.
✤ Build,Compile and Run
✤ Check logs and other cool stuff in DDMS
✤ Debug if necessary!
26. How to publish Android Apps?
Before you consider your application ready for release:
1.Test your application extensively on an actual device
2.Consider adding an End User License Agreement in your application
3.Consider adding licensing support
4.Specify an icon and label in the application's manifest
5.Turn off logging and debugging and clean up data/files
Before you do the final compile of your application:
1.Version your application
2.Obtain a suitable cryptographic key
3.Register for a Maps API Key, if your application is using MapView elements
Compile your application
After you compile your application:
•Sign your application
•Test your compiled application
27. How to publish Android Apps?
1.) When testing was successfully passed ( you think so?)
• ) Go to Android Market
1.) Create an account (pay $25 one time devoper fee)
• ) Follow instructions from there
1.) Congratulations you just published your first ever Android
Application
• ) Now wait for the revenue to get into your bank!
* Check on the customers feedback it will help you create the
application much better!
28. February 19, 2011 @ De La Salle University - Dasmariñas
Your Turn...
Hands-on , creating your first Android Application
29. February 19, 2011 @ De La Salle University - Dasmariñas
Need more information about Android?
We are done...got questions?