Top Banner
INTRODUCTION TO ANDROID DEVELOPMENT Adejuwon Omolara Twitter: @_larikraun Email: [email protected]
30

Intro to android (gdays)

Jul 17, 2015

Download

Software

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: Intro to android (gdays)

INTRODUCTIONTOANDROIDDEVELOPMENT

Adejuwon Omolara

Twitter: @_larikraun

Email: [email protected]

Page 2: Intro to android (gdays)

Overview

• Android is a software stack for mobile devices that includes an operating system, middleware and key applications.

• Android OS is divided into five sections

• Applications: This is where applications to be installed are written. E.g. Games,

Browser etc.

• Application Framework: This layer provides many higher-level services to

applications in the form of Java classes.

• Android Runtime: This section provides a key component called Dalvik Virtual

Machine. Dalvik VM enables every android application to run in its own process, with

its own instance of the Dalvik VM. Dalvik VM is optimised to run on slow CPU, low

RAM, low power devices. It runs .dex files and not .class nor .jar

• Libraries: e.g. SQLite database, repository for storage and sharing of application.

• Linux Kernel : it provides basic system functionality e.g. process management,

device management etc.

Page 3: Intro to android (gdays)

Platform Overview

Page 4: Intro to android (gdays)

Android has evolved over the years :

• Android 1.1 *Not relevant in the ecosystem*

• Android 1.5 Cupcake *Not relevant in the ecosystem*

• Android 1.6 Donut *Not relevant in the ecosystem*

• Android 2.0/2.1 Eclair *Not relevant in the ecosystem*

• Android 2.2.x Froyo *Not too relevant in the ecosystem*

• Android 2.3.x Gingerbread *Still somewhat relevant in the ecosystem*

• Android 3. x Honeycomb *Not relevant in the ecosystem*

• Android 4.0.x Ice Cream Sandwich *Still quite relevant in the ecosystem*

• Android 4.1, 4.2, 4.3 Jelly Bean *Very relevant in the ecosystem*

• Android 4.4 KitKat *Very relevant in the ecosystem*

• Android 5.0 Lollipop * Gaining relevance in the ecosystem*

Page 5: Intro to android (gdays)

And now we have Lollipop…

Page 6: Intro to android (gdays)

Tools you need to get started…

• A fair knowledge of Java

• Latest Java Development Kit (JDK) : Android Apps are

developed using Java.

http://www.oracle.com/technetwork/java/javase/downloads/inde

x.html

• Eclipse Integrated Development Environment (IDE)

https://www.eclipse.org/downloads/ or any other suitable IDE.

• Android SDK

http://developer.android.com

• ADT Tools for Eclipse (via Internet)

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

• Android Virtual Device (AVD) or an android mobile device.

Page 7: Intro to android (gdays)

Application Components

Applications use four main components:

• Activity

• Service

• Broadcast Receivers

• Content Providers

Page 8: Intro to android (gdays)

Activity

Activities: A single screen that is visible to user. They dictate the UI and

handle the user interaction to the smartphone screen.

public class MainActivity extends Activity {

}

Page 9: Intro to android (gdays)

Activity Lifecycle

Page 10: Intro to android (gdays)

Services

Services: They handle background processes associated with an

application. They can be used to update an application when it’s not

active.

public class MyService extends Service {

}

Page 11: Intro to android (gdays)

Service Lifecycle

Page 12: Intro to android (gdays)

Broadcast Receiver

Broadcast Receivers: They handle communication between Android OS

and applications. They listen for android system events.

public class MyReceiver extends BroadcastReceiver {

}

Page 13: Intro to android (gdays)

Content Providers

Content Providers: They handle and manage data, usually stored in

database and data access for queries.

public class MyContentProvider extends ContentProvider {

}

Page 14: Intro to android (gdays)

More Components…

• Fragments: Represents a behaviour or a portion of user

interface.

• Views: UI elements that are drawn onscreen. They are

responsible for event handling e.g. ContextMenu, Menu etc.

• Widgets: They are more advanced UI elements e.g Button,

CheckBox, ImageView etc.

• Layouts: View hierarchies that control screen format and

appearance of the views.

Page 15: Intro to android (gdays)

• Intents: Messages wiring components together. An intent

is composed of an action it needs to perform. They are

used to start activities and to communicate among various

parts of the android system.

• Resources: External elements such as strings, drawables

and constants

• Manifest: Configuration file for the application.

Page 16: Intro to android (gdays)

Layout Manager

It is responsible for the layout of itself and its child Views.

Android supports different default layout managers. To get

a desired layout, there are some few terms you would

come across.

android:layout_width defines the width of the widget.

android:layout_heigth defines the height of the widget.

match_parent tells the application to maximize the

widget in its parent.

wrap_content tells the layout to allocate the minimum

amount so that the widget is rendered correctly.

Page 17: Intro to android (gdays)

Image source: vogella

Page 18: Intro to android (gdays)

Who doesn’t like easy tasks? Well, I do…

Google exposes a number of functionalities in android. To

create spectacular apps, you should make use of them.• Touchscreen

• GPS

• Accelerometer

• Internet

• Audio and Video support

• Contacts

• Security

• Google APIs

Page 19: Intro to android (gdays)

API levels

This is an integer value that uniquely identifies the

framework API revision offered by a version of the android

platform.

It lets the android platform describe the maximum

framework API revision that it supports.

It lets applications describe the framework API revision

that they require.

It lets the system negotiate the installation of applications

on the user’s device such that version-incompatible are

not installed.

You can catch more gist on API levels here

Page 20: Intro to android (gdays)
Page 22: Intro to android (gdays)

My One-Dollar

To write a working android application, you need to

consider keeping it simple. Nobody likes a complex-for-

nothing application. I encourage drawing mock-ups ( a

visual representation of how you want the application to

look like), flow charts ( a step-by-step approach to

achieving your goal) as one of the first steps before

jumping on your IDE.

You will need to step up your UI/UX game to ‘wow’ your

users.

Page 23: Intro to android (gdays)

I think these will help too

• Make Google your friend

• Get familiar with android developers’ site

• Read documentations before using any API

• Join forums that will help. One of the most popular is

stackoverflow

• Get close to the ‘gurus’- they have a lot to offer.

• Read books that will help.

Page 24: Intro to android (gdays)

My ‘Hello World’ Application

This is a dummy application that just displays ‘Hello World,

MyFirstApp’

MyFirstApp.java + main.xml =

Page 25: Intro to android (gdays)

MyFirstApp.java

Page 26: Intro to android (gdays)

The main.xml file

Page 27: Intro to android (gdays)

AndroidManifest.xml

Page 28: Intro to android (gdays)

package attribute defines the base package for the Java objects referred to in

a particular file.

android:versionCode must be an integer. You typically start from ‘1’ and

increase the value by one if you roll-out a new version of your application.

android:versionName is what the users see. It can be any string.

android:minSdkVersion defines the minimum version of android your

applicaton works on. A user cannot install your application on a device with a

lower API level than specified in this attribute.

android:targetSdkVersion specifies the version on which you tested and

developed. It is a good practice to always set this to the latest Android API

version.

Page 29: Intro to android (gdays)

<application> section is a container for declaring android components.

<activity> tag defines an activity component.

android:name="android.intent.action.MAIN" can be started and the category

android:name="android.intent.category.LAUNCHER“ parameter tells the

Android system to add the activity to the launcher.

Page 30: Intro to android (gdays)

Questions???