Top Banner
February 19, 2011 @ De La Salle University - Dasmariñas Part 2: Android Application Development 101 Mike Rivera - Señior Android Developer @ Excitor Asia
30

Part 2 android application development 101

May 10, 2015

Download

Technology

Development proper
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Part 2 android application development 101

February 19, 2011 @ De La Salle University - Dasmariñas

Part 2: Android Application Development 101Mike Rivera - Señior Android Developer @ Excitor Asia

Page 2: Part 2 android application development 101

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?

✤ Creating your first your Android Application.

Page 3: Part 2 android application development 101

February 19, 2011 @ De La Salle University - Dasmariñas

First things firstTools you need to learn and understand.

Page 4: Part 2 android application development 101

Tools needed

✤ Java SDK

✤ Eclipse IDE

✤ Android SDK

✤ Android Developer Tool (ADT , Eclipse Plug-in)

✤ YOU!

Page 5: Part 2 android application development 101

Java SDK

Go To > http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download Java Development Kit (JDK) 6 Update 22(or higher)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Page 6: Part 2 android application development 101

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 !

Page 7: Part 2 android application development 101

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!)

Page 8: Part 2 android application development 101

Eclipse IDE

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

Install JDK to your local drive (remember the location)

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)

Page 9: Part 2 android application development 101

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

Page 10: Part 2 android application development 101

Android Application Components

✤ Activites

✤ Services

✤ BroadcastReceivers

✤ ContentProviders

Intents

Page 11: Part 2 android application development 101

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.

Page 12: Part 2 android application development 101

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.

Page 13: Part 2 android application development 101

Services

✤ Represents events or actions

✤ Do not interact with the users.

✤ Can update your data sources and Activities, and trigger specific notifications.

Page 14: Part 2 android application development 101

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.

Page 15: Part 2 android application development 101

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.

Page 16: Part 2 android application development 101

User Interfaces

✤ There are two UI approaches: procedural and declarative (xml code)

✤ You can mix both approaches.

Page 17: Part 2 android application development 101

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);

Page 18: Part 2 android application development 101

UI: Views and ViewGroups

Page 19: Part 2 android application development 101

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.

Page 20: Part 2 android application development 101

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

Page 21: Part 2 android application development 101

UI: Dialogs and Menus

Dialogsa small window that appears in front of the current Activity (Alert,Progress,DatePicker, TimePicker and a custom one)

MenusConcerned about having to much functionality on the screen => use menus

Page 22: Part 2 android application development 101

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

Page 23: Part 2 android application development 101

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.

Page 24: Part 2 android application development 101

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest . . . > <application . . . > <activity android:name="com.example.FreneticActivity" android:icon="@drawable/small_pic.png" android:label="@string/freneticLabel" . . . > </activity> . . . </application></manifest>

Page 25: Part 2 android application development 101

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!

Page 26: Part 2 android application development 101

How to publish Android Apps?

Before you consider your application ready for release:1.Test your application extensively on an actual device2.Consider adding an End User License Agreement in your application3.Consider adding licensing support4.Specify an icon and label in the application's manifest5.Turn off logging and debugging and clean up data/filesBefore you do the final compile of your application:1.Version your application2.Obtain a suitable cryptographic key3.Register for a Maps API Key, if your application is using MapView elementsCompile your applicationAfter you compile your application:•Sign your application•Test your compiled application

Page 27: Part 2 android application development 101

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 there1.) 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!

Page 28: Part 2 android application development 101

February 19, 2011 @ De La Salle University - Dasmariñas

Your Turn...Hands-on , creating your first Android Application

Page 29: Part 2 android application development 101

February 19, 2011 @ De La Salle University - Dasmariñas

Need more information about Android?

We are done...got questions?

Page 30: Part 2 android application development 101

30

References• http://en.wikipedia.org/wiki/Android_(operating_sy

stem)

• http://www.ibm.com/developerworks/opensource/library/os-android-devel/

• http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-Application-Development.productCd-0470344717.html

• http://groups.google.com/group/android-beginners

• http://developer.android.com/index.html

• Androidtapp.com

• Ed Brunette Hello Android30