57
Android App Development Beyond The HelloWorld App Cape Town Android Meetup Joseph Kandi Peruzal Android App Development Training Team www.peruzal.co.za

Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Embed Size (px)

DESCRIPTION

Learn the core Android App development concepts beyond creating the Android App. We used the Yamba app from the Learning Android demonstrate the use of Android Activities, Services, Broadcast Receivers, Intents and Content Providers.

Citation preview

Page 1: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android App Development Beyond The HelloWorld App

Cape Town Android MeetupJoseph Kandi

Peruzal Android App Development Training Team

www.peruzal.co.za

Page 2: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Take Aways

!Android Development Environment Android Application Components Threads in Android Designing Android UIs in XML Using Intents Performing Web Service Calls

Page 3: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android Development Environment

• Java

• Eclipse | Android Studio

• Android SDK

Page 4: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Java Skill Level

• Variables

• Operators

• String

• Loops

• Methods

• Class

• Static

• Inheritance

• Packages and Import

• Access Levels

• Constants

• Interface

• Inheritance

• Abstract

• Generics

• Casting

• Threads

• Enum

• Exception Handling

• Boxing and UnBoxing

Page 5: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android and Java

Page 6: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android Software Stack

Custom Linux 2.6 kernel

SQLite, WebKit, SSL, OpenGL ES, Media

Framework

Content Providers, Activity Manager, Window Manager, View

System, Notification System, Telephony Home, Contacts, Browser,

Yamba

Page 7: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Inside Android

System partition

Use command adb shell to logon to the device

Note the permissions on the folders

sdcard

Page 8: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android Versions and API Level

Page 9: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Get Java

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Page 10: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Eclipse

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

Download from this link

Page 11: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android Studio

Still buggy, not ideal for beginners to Android development

Download from here

Page 12: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Building Blocks

Activities Services Content Providers Broadcast Receivers Application

Page 13: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Activity

An activity is a single, focused thing that the user can do.

Page 14: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Activity Life Cycle

Page 15: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Activity Class

Called the activity is first created

Called when the activity is becoming visible to the user

Called after the activity has been stopped, prior to it being

started again

Called when the activity will start interacting with the user

Called when the system is about to start resuming a

previous activity Called when activity is no longer visible

Final call before the activity is destroyed

Page 16: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Intents

Messages sent among the major building blocks. They trigger an action to start up, tell a service to start or stop, or simple

broadcast

Page 17: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Services

Services run in the background and don’t have a user interface components

Page 18: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Content Providers

Interfaces for sharing data

Page 19: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Broadcast Receivers

Android implementation of publish/subscribe mechanism or the Observer pattern

Page 20: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Application Context

Refers to the application environment and the process within which all the components are running !

Used to share data between components

Context.getApplicationContext

Activity.getApplication

Page 21: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Android User Interface

Java - done in code XML - declarative

Page 22: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Views

Android organizes its UI into layout and views

Page 23: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Write the xml

Load the XML Resource

Page 24: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Layouts

Page 25: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Example Linear Layout

Also called match_parent

Either

Page 26: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 27: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Relative Example

Page 28: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 29: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 30: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Creating a New Project

• Walkthrough, create a new project

Page 31: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Choose New Project

Page 32: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

The name of the appProject Name - NB No spaces allowed

Package name, usually reverse dns of your company name

Minimum supported SDK the app will run on

The version of Android we are

building forDoes not do anything,

ignore

Create an initial activity

Page 33: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Customize the launcher

Preview of the launch icon on different screen resolutions

Path for the image used as a launch icon on the home screen

Page 34: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Choose Activity Type

Choose different activity types

Choose “Blank Activity” here

Page 35: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Choose Main Activity Name

Leave it as MainActivity for now, in future we will change it

The xml file defining the user interface for our

activity

Leave as is

Page 36: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Project Structure

Main activity created during project

setup

Resource folders go under “res” folder

xml layout file defining the screen for

the app

Explains what application consists, the main building

blocks, permissions

Page 37: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

AndroidMainfest.xml

Package name for the application

Android SDK

Activity declaration

Main activity action

Intent Category of the action

Page 38: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Layout xmlLive preview

xml defining the UI

File lives under “layout” resource folder

Page 39: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Layout container

xml properties

View component

Main Activity xml file

Page 40: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Java file

Extends Activity class

Using the class R to point to the layout

Page 41: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

R file | Auto-generated

R.layout.activity_main, referring to the file under /layout/activity_main.xml

Page 42: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

strings.xml

Key used to retrieve the string

Value

Page 43: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

AVD | Android Virtual Device Launch AVD manager

Launch AVD manager

Page 44: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

AVD ManagerAVD images

Available devices, need at least one to test the app

Add a new AVD

Page 45: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Create a New AVD

Choose name, no spaces allowed

Choose device specifications

Camera support

Amount of RAM

Improves speed of the emulator

Android SDK version

Page 46: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

User Interface and Controls

• Project Overview

Page 47: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Project Overview

Yamba App Context

TwitterService

StatusActivity

poststatusupdate

1

Page 48: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 49: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 50: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 51: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 52: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 53: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup
Page 54: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Status Activity

Page 55: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Timeline Activity

Page 56: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Action Bar | Menu

Page 57: Learn how to develop for Android, beyond the Hello World android app - Cape Town Android Meetup

Preferences