Android introduction

download Android introduction

If you can't read please download the document

Transcript of Android introduction

1

2/12/16

2/12/16





2/12/16

2/12/16









2/12/16









2/12/16

2/12/16

2/12/16





2/12/16

2/12/16

2/12/16

2/12/16





2/12/16





2/12/16

Introduction to Android Programming

Tools

Eclipse for Java Developers

Android SDK

Android Developer Tools

Example

Eclipse for Java Developers

Android SDK

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

Adding SDK Packages

Android Developer Tools

Installing the Eclipse Plugin

1. Start Eclipse, then selectHelp>Install New Software.

2. ClickAdd, in the top-right corner.

3. In the Add Repository dialog that appears, enter "ADT Plugin" for theNameand the following URL for theLocation:

https://dl-ssl.google.com/android/eclipse/


Android Developer Tools

Configure the ADT Plugin

1. In the "Welcome to Android Development" window that appears, selectUse existing SDKs.

2. Browse and select the location of the Android SDK directory you recently downloaded and unpacked.

3. ClickNext.


Android Developer Tools

AVD

Hardware Accelerated

Create Android Application

Follow the option File -> New -> Project and finally select Android New Application wizard from the wizard list.

Now name your application as HelloWorld using the wizard window as follows:

Create Android Application

Configure Launcher Icon

Don't Create Activity

Project Structure

Anatomy of Android Application

srcThis contains the .java source files for your project.

genThis contains the .R file, a compiler-generated file that references all the resources found in your project.

binThis folder contains the Android package files .apk built by the ADT during the build process and everything else needed to run an Android application.

Anatomy of Android Application

res/drawable-hdpiThis is a directory for drawable objects that are designed for high-density screens

res/layoutThis is a directory for files that define your app's user interface.

res/valuesThis is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.

AndroidManifest.xmlThis is the manifest file which describes the fundamental characteristics of the app and defines each of its components.

Create an Android layout XML file

activity_main

User Interface(UI)

XML Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

XML

activity_main.xml

AndroidManifest.xml

UI Overview

Common Layouts

Linear

Relative

List View

Grid View

References: Layouts

Linear Layout

Relative Layout

List View Layout

Grid View Layout

Example

UiDemo

Activity

7onCreate()

onStart()

onResume()

onPause()Activity

onStop()

onRestart() onStop()onStart()

onDestroy()

Activity

http://developer.android.com/training/basics/activity-lifecycle/starting.html

Activity

onCreate -> onStart -> onResume

ActivityonPause(1) -> onCreate(2) -> onStart(2) - onResume(2) -> onStop(1)

ActivityonPause(2) -> onRestart(1) -> onStart(1) -> onResume(1) -> onStop(2) -> onDestroy(2)

onPause -> onStop -> onDestroy

Activity

Resumed"running" state.

PausedActivity

Stopped

Example Project

UiDemo

Android

(Applications)

(Application Framework)

(Libraries)

Android (Android Runtime)

Linux (Linux Kernel)

Android

Dashboards

https://developer.android.com/about/dashboards/index.html

Example

****

Contact

E-mail: pinglunliao [at] gmail [dot] com

LINE: Holan.Liao

Skype: pinglunliao

FB: https://www.facebook.com/LiaoPingLun

References

http://gogkmit.wikidot.com/start