PowerPoint Presentation

Document Sample
PowerPoint Presentation Powered By Docstoc
					Android Training

    Nelson To
PreInstall Components

• Android SDK • http://code.google.co...
• Java Standard Development Kit (JDK) version 5.0/6.0 (download)
   o If you already have installed JDK 5.0/6.0, you can skip this.
• Eclipse Ganymede • http://eclipse.org/do...
• Eclipse ADT Plugin • https://dl-ssl.google...
What is Android

•   Android is not an operating system
•   Android is build on top of Linux Kernel
•   Android is not equivalent to Linux Kernel
•   Android is an open source
•   Android devices sales 160,000 per day
Android and Java

• Android does not use the standard JVM
• Android own its own JVM(Dalvik)
• Android Dalvik vs standard JVM
  o register-based vs stack-based
  o more efficient and compact implementation
  o different set of java libraries than standard java libraries
Android FrameWork Stack
Android Linux Kernel

•   Hardware abstraction layer
•   Memory Management
•   Process Management
•   Networking
•   ...
Android Native Libraries

•   Bionic
•   Surface Manager
•   2D and 3D grahics
•   Media codecs
•   SQLite
•   WebKit
•   ...
Android Framework

•   ActivityManager
•   Content providers
•   Resource manager
•   Location Manager
•   Notification Manager
•   ...
Android Application

• Android applications
  o google maps
  o facebook
  o twitter
  o ...

• Tools
• Docs
• Platforms
   o Android XX
       Data
       Skins
       Images
       Samples
• Add-ons
   o Google API
Android Process and Thread

• Linux process per application
• One thread per process
   o UI Thread
   o manage Looper message
Android Application Components

•   Activity
•   Service
•   Broadcast receiver
•   Content provider
Android Activity

• a single, focused thing that the user can do
• takes care of creating a window for user
• presentation to the user
   o full-screen windows
   o floating windows
   o embedding inside of another activity
• lifecycle
   o void onCreate(Bundle savedInstanceState)
   o void onStart()
   o void onRestart()
   o void onResume()
   o void onPause()
   o void onStop()
   o void onDestroy()
Android Service

• to perform a longer-running operation while not interacting with
  the user
• can be started and stopped
• doesn't have UI
• run by activities
• implicit Service (binding service)
• explicit Service (start service)
• lifecycle
   o void onCreate()
   o void onStart(Intent intent)
   o void onDestroy()
Android Content Provider

• store and retrieve data and make it accessible to all applications
• to share data across applications
Android Broadcast Receiver

• receive intents sent by sendBroadcast()
• two type of broadcasts
   o Normal broadcast
   o Ordered broadcast
Android Activity LifeCycle
Android Intents

• an abstract description of an operation to be performed
   o action
   o data
• Explicit Intents (specified a component)
• Implicit Intents
Hello World Project

•   Projec Name
•   Target
•   Application Name
•   Package name
•   Min SDK version
Hello World Project

•   src
•   gen
•   Android XX
•   res
•   assets
Hello World Project

Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".helloworld"
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
  <uses-sdk android:minSdkVersion="4" />
Hello World Project

Layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Hello World Project


package com.teach.helloworld;

import android.app.Activity;
import android.os.Bundle;

public class helloworld extends Activity {
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
Hello World Project


package com.teach.helloworld;

public final class R {
  public static final class attr {
  public static final class drawable {
     public static final int icon=0x7f020000;
  public static final class layout {
     public static final int main=0x7f030000;
  public static final class string {
     public static final int app_name=0x7f040001;
     public static final int hello=0x7f040000;

Shared By: