Android – Developer Intro_Android

Document Sample
 Android – Developer Intro_Android Powered By Docstoc
Developer Introduction

         Eric Faccer
        Presentation Overview
•   Dream/ADP1 Handset Overview
•   The Android SDK
•   The Android Software Stack
•   Advanced Concepts
•   Web Resources
             HTC Dream
•   Qualcomm ARM based CPU
•   Camera
•   Accelerometer
•   GPS, Digital Compass
•   WIFI, Bluetooth
•   TouchScreen
•   3D Graphics
              Other Devices
•   Openmoko FreeRunner
•   Motorola A1200 Ming
•   HTC Vogue
•   HTC Touch
•   Nokia N810
•   Nokia 770
•   Asus EEEPC 701
•   Asus EEEPC 1000H
•   Always Innovating Touch Book
•   Dell Axim x51v
       Open Handset Alliance
• Mobile Phone Consortium dedicated to open
  standards for mobile devices.

• Google, HTC, Intel, Samsung, Motorola,
  Qualcomm, T-Mobile, Sprint Nextel, Nvidia,
  Sony Ericsson, Vodaphone, ARM Holdings,
  Asustek, Toshiba, Garmin.

• Nokia has hedged their bets and reportedly has
  a large team working on android.
                   What is Android
•   Custom Linux Distribution and Java-based Virtual Machine

•   Based on the Java language 1.5 standard

•   Java is an overloaded term. It refers to:
     – A language with a distinct syntax/grammar
     – A class library
     – A stack based virtual machine

•   Android has implemented their own VM called Dalvik. Dalvik is
    different because it uses a register based VM architecture.

•   The practical consequence of the decision to drop the Java VM is
    standard java classes cannot be used on android without
What is Android
  SDK Demo & Tools Overview
• Eclipse Plugin
• HierarchyViewer

• Activitycreator
• Aapt Tool
• Dx
                  Activity class
• Roughly corresponds to a single “screen”

• Your application’s entry point.

• Does not require a user interface, but that would be

• When a new screen opens, the previous screen is
  paused and put onto a history stack. The user can then
  navigate backwards through previously opened screens
  in the history. Screens can also be removed from the
  history stack when it would be inappropriate for them to
               Service class
• Application component that runs in the
  background, for an indefinite period of time.

• OpenBinder – System Level IPC and
  Component Framework

• Local Services and Remote Services
• Remote Services require using aidl and
  Parcelable classes
   Activity or Service Blocking
• Use Threads liberally.

• If your application or service blocks, the
  ActivityManager will come over and throw
  up a nasty ANR error for Application Not

• If you start getting these, you know what to
• A means for publishing application
  Service Registration:
  <service android:name= "" />

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

      <action android:name=""/>
      <action android:name=""/>
               Intent class
• An intent is a description of an operation to
  be performed.

• It can be used with Activity.startActivity() to
  launch an Activity or Context.BindService()
  to communicate with a Service. It can be
  broadcast system-wide to send it to any
  interested BroadcastReceiver components
                Intent Example
Intent myIntent = new Intent(

Will open up the Maps Activity with the specified
• Android SDK apps have no access to the
  underlying filesystem (except /sdcard)
• Resources are build time artifacts (files) that are
  included in your application package.

   res/drawable   – for images png/jpg, etc.
   res/layout     – for xml layout files
   res/menu       – for xml based menu specifications
   res/values     – for strings, dimensions, etc.
   res/anim       – for animations

   res/raw        – for raw files
•   A means to respond to system level events

•   The interface consists of a single method:
    onReceive() { }

•   To use in your Activity:
•   registerReceiver() in your Activity’s onResume() callback
•   unRegisterReceiver() in your Activity’s onPause() method

•   You can’t use it as an arbitrary message bus, because it will miss
    messages when the it’s Activity is inactive.

•   This holds even if you fail to unregister the receiver. Unregistering
    the receiver is merely good practice that reduces the system
    overhead by a small amount.
            Content Provider
• A means for sharing tabular data across

• It is a class that implements a standard set of
  methods to let other applications store and
  retrieve the type of data that is handled by that
  content provider.

• Uses sqlite backend for relational data storage
            Android User Interface
• May be defined using XML files or by writing standard
  java code

• XML Caveats
   – The XML parser and renderer have a lot of bugs.
     This crashes eclipse alot.
   <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android=""
       android:orientation="vertical" android:layout_width="fill_parent“
       <TextView android:layout_width="wrap_content" android:layout_height="wrap_content“
       android:text="Hello World"/>

  WYSIWYG tool at
• FrameLayout
  – contains a single object
• LinearLayout
  – aligns all children in a single direction
• TableLayout
  – positions its children into rows and columns
• AbsoluteLayout
  – absolute positioning
  – children specify their position relative to the parent
    view or to each other
         Handling UI events
• Handle events the standard way:
• EventListeners
  – onClick()
• EventHandlers
  – onTouchEvent(MotionEvent)
Crossing Things Off of Lists

                 Credit: Jeff Sharkey
             Further Reading
•   #android, #android-dev on

        Advanced Concepts