CS6320 ANDROID L Grewe Components Android SDK http code google co Java Standard Development Kit JDK version 5 0 6 0 download http www oracle com or latest version o If you already have installed JDK 5 0 6 0 you can skip this Eclipse Helios http eclipse org dowloads 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 2010 numbers 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 AndroidSDK 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 Android application collection of loosly coupled components Activity Service Intents and Broadcast receiver Intents reciever Content provider Android Activity The building block of the user interface The Android analogue for the window or dialog in a desktop application 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 Examples checking for updates to an RSS feed playing back music even if the controlling activity is no longer operating Android Content Provider store and retrieve data and make it accessible to all applications to share data across applications Intents Intents are system messages running around the inside of the device notifying applications of various events hardware state changes e g an SD card was inserted incoming data e g an SMS message arrived application events e g your activity was launched from the device s main menu How to create Intents You can receive and respond to intents by intent filters intent broadcast receivers You can create your own intents to launch other activities let you know when specific situations arise e g raise an intent when the user gets within 100 meters of a specified location Android Broadcast Receiver Intents 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 Project basics Java based project AndroidManifest xml an XML file describing the application being built and what components activities services etc are being supplied by that application build xml an Ant script for compiling the application and installing it on the device integrated with IDE default properties a property file used by the compiler res contains multiple xml files and other resources used by application Project basics src holds the Java source code for the application gens contains generated Java code R java this points to resources used DO NOT edit this by hand let IDE autogenerate it assets hold other static files you wish packaged with the application for deployment onto the device Hello World Project Manifest file Define Application see res strings xml see res drawable resolution icon png xml version 1 0 encoding utf 8 manifest xmlns android http schemas android com apk res android package com teach helloworld android versionCode 1 android versionName 1 0 application android icon drawable icon android label string app name activity android name helloworld android label string app name intent filter action android name android intent action MAIN category android name android intent category LAUNCHER intent filter activity application Here have intent created for uses sdk android minSdkVersion 4 This acitivity that is associated with manifest launch of application Hello World Project Layout file xml version 1 0 encoding utf 8 LinearLayout xmlns android http schemas android com apk res android android orientation vertical android layout width fill parent android layout height fill parent TextView android layout width fill parent android layout height wrap content android text string hello LinearLayout Create an Activity with simple text Interface first An Android user interface is composed of hierarchies of objects called Views A View is a drawable object used as an element in your UI layout such as a button image or In the next code will create a text label Each of these objects is a subclass of the View class and the subclass that handles text is TextView Hello World Project Helloworld java package com teach helloworld import android app Activity import android os Bundle create a TextView with the class constructor which accepts an Android Context instance as its parameter Context is a handle to the system provides services like resolving resources obtaining access to databases and preferences etc The Activity class inherits from Context and because your HelloAndroid class is a subclass of Activity it is also a Context So you can pass this as your Context reference to the TextView public class helloworld extends Activity Called when the activity is first created Override public void onCreate Bundle savedInstanceState super onCreate savedInstanceState TextView tv new TextView this tv setText Hello Android Lynne setContentView tv text content is set with
View Full Document
Unlocking...