240 likes | 363 Views
Android Training. Nelson To. PreInstall Components . Android SDK • http://code.google.co... Java Standard Development Kit (JDK) version 5.0/6.0 (download) http://www.oracle.com... If you already have installed JDK 5.0/6.0, you can skip this. Eclipse Ganymede • http://eclipse.org/do...
E N D
Android Training Nelson To
PreInstall Components • Android SDK • http://code.google.co... • Java Standard Development Kit (JDK) version 5.0/6.0 (download) http://www.oracle.com... • 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 • register-based vs stack-based • more efficient and compact implementation • different set of java libraries than standard java libraries
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 • google maps • facebook • twitter • ...
AndroidSDK • Tools • Docs • Platforms • Android XX • Data • Skins • Images • Samples • Add-ons • Google API
Android Process and Thread • Linux process per application • One thread per process • UI Thread • 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 • full-screen windows • floating windows • embedding inside of another activity • lifecycle • void onCreate(Bundle savedInstanceState) • void onStart() • void onRestart() • void onResume() • void onPause() • void onStop() • 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 • void onCreate() • void onStart(Intent intent) • 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 • Normal broadcast • Ordered broadcast
Android Intents • an abstract description of an operation to be performed • action • 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" 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> <uses-sdk android:minSdkVersion="4" /></manifest>
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>
Hello World Project Helloworld.java package com.teach.helloworld;import android.app.Activity;import android.os.Bundle;public class helloworld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }}
Hello World Project R.java 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; }}