图示:
从图上来看,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>