圖示:
從圖上來看,Android系統一共分了4層:
1、Linux內核:Android是運行在Linux kernel2.6之上,但是把linux內受GNU協議約束的部分做了取代,這樣在Android的程序可以用於商業目的
2、中間件(包括核心庫和運行時):媒體庫、Sqlite、webkit、Dalvik虛擬機等
3、應用程序框架:Activity管理、消息管理器等
4、應用程序:這裏指內置的應用程序,都使用Java編寫
程序結構簡介:
代碼結構:
MainActivity.java:代碼實現,例如:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(tag,"onCreate");
}
main.xml:有關界面佈局和設計,例如:
<?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">
</LinearLayout>
AndroidManifest.xml:向Android系統描述所包含的組件、所實現的功能、能處理的數據等,例如:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.firstapp.MainActivity"
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>
</manifest>