安卓開發_淺談主設定檔(AndroidManifest.xml)

來源:互聯網
上載者:User

標籤:

AndroidManifest.xml
本質:是整個應用的主配置資訊清單檔
包含:該應用的包名,版本號碼,組件,許可權等資訊
作用:記錄該應用的相關的配置資訊

一、常用標籤
(1)、全域篇(包名,版本資訊)
(2)、組件篇(四大組件)、
(3)、許可權篇(申請許可權和定義許可權)
1、全域篇
(1)、應用的包名以及版本資訊的管理
package="com.example.tset"
android:versionCode="1"
android:versionName="1.0">
(2)、控制android版本的資訊(可以支援的最低版本,你期望的系統版本)
android:minSdkVersion="8"
android:targetSdkVersion="16"
2、組件篇
<application android:icon="@drawable/icon"
android:theme="@style/my_theme">
</application>
其屬性可以設定:
(1)、表徵圖:android:icon
(2)、標題:android;label
(3)、主題樣式:android:theme

在設定檔中註冊組件

(1)、定義Activity

<activity
android:name="com.example.allcode.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
>

<intent-filter>
<action android:name="android.intent.action.MAIN" /> //作為主activity
<category android:name="android.intent.category.LAUNCHER" /> //顯示在軟體列表中
</intent-filter>
</activity>
註:啟動一個沒有在清單中定義的Activity會拋出異常
(2)、定義Service(服務)
<sevice android:name="com.ttg.service.CouponService"
<intent-filter>
<action android:name="com.ttg.service"</action>
</intent-filter>
</seivice>
(3)、Content Provider(內容提供者)
<provider android:name="com.example.manifest.provider">
</provider>
內容提供者用來管理資料庫訪問及程式內和程式間共用的
(4)、Broadcast Receiver(廣播接收者)
<receiver android:name="com.ttg.receiver.CouponService"
<intent-filter>
<action android:name="com.ttg.install"</action>
</intent-filter>
</receiver>

 

安卓開發_淺談主設定檔(AndroidManifest.xml)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.