Android_Intro_Training

advertisement
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...
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 ...
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
•
•
•
•
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"
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;
}
}
Download
Related flashcards
Create Flashcards