2012年3月20日 星期二

Andoriday 2 - Pure Source Code

1.  ----Android Manifest.xml-----

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="Lai_Yan.example"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".MY_BlueTooth_AppActivity"
            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>


2.   src/Activity . java
package Lai_Yan.example;

import android.app.Activity;
import android.os.Bundle;

public class MY_BlueTooth_AppActivity extends Activity {
    /** Called when the activity is first created. */
 



@Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.main);}
 
 
 
}

3./res/main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>


4./res/String

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <string name="hello">Hello World, MY_BlueTooth_AppActivity!</string>
    <string name="app_name">MY_BlueTooth_App</string>
</resources>




上面三個檔案存在的目的,只有一個原因,透過四者間的人機介面資料傳遞
讓Android 認得觸碰螢幕產生的事件,再透過Java Dalvik 跟Linux底層系統溝通從這裡開始讓
Android 系統 Working。

接下來開始就是 Android 系統 跟 程式架構上的問題了。


Android Manifest.xml  本身 是要描述 這個APP 本身所有的資訊
http://developer.android.com/guide/topics/manifest/manifest-intro.html

特別是在權限上的處理,有諸多描述,簡單說要跟Android系統要資源或權限
都要在這裡宣告才能跟系統溝通,不論使用系統內資源包、作業系統的多執行緒
或是存在Android 系統下的型態,簡單說就是APP本身要如何存在於Android都是要透過
Manifest 去描述,看來這個是非常複雜的東西,有機會才能深入,目前針對題目Bluetooth connect 來說的話應該是初淺便可。

沒有留言:

張貼留言