android studio 清單配置文件androidmainfest.xml詳細(xì)解讀
AndroidManifest是什么?
AndroidManifest官方解釋是應(yīng)用清單(manifest意思是貨單),每個(gè)應(yīng)用的根目錄中都必須包含一個(gè),并且文件名必須一模一樣。這個(gè)文件中包含了APP的配置信息,系統(tǒng)需要根據(jù)里面的內(nèi)容運(yùn)行APP的代碼,顯示界面。
AndroidManifest的作用是什么?
上述的功能是非常籠統(tǒng)的解釋,具體到細(xì)節(jié)就是:
- 為應(yīng)用的 Java 軟件包命名。軟件包名稱充當(dāng)應(yīng)用的唯一標(biāo)識(shí)符。
- 描述應(yīng)用的各個(gè)組件,包括構(gòu)成應(yīng)用的 Activity、服務(wù)、廣播接收器和內(nèi)容提供程序。它還為實(shí)現(xiàn)每個(gè)組件的類命名并發(fā)布其功能,例如它們可以處理的 Intent 消息。這些聲明向 Android 系統(tǒng)告知有關(guān)組件以及可以啟動(dòng)這些組件的條件的信息。
- 確定托管應(yīng)用組件的進(jìn)程。
- 聲明應(yīng)用必須具備哪些權(quán)限才能訪問 API 中受保護(hù)的部分并與其他應(yīng)用交互。還聲明其他應(yīng)用與該應(yīng)用組件交互所需具備的權(quán)限
- 列出 Instrumentation類,這些類可在應(yīng)用運(yùn)行時(shí)提供分析和其他信息。這些聲明只會(huì)在應(yīng)用處于開發(fā)階段時(shí)出現(xiàn)在清單中,在應(yīng)用發(fā)布之前將移除。
- 聲明應(yīng)用所需的最低 Android API 級(jí)別
- 列出應(yīng)用必須鏈接到的庫
上面是官方的解釋。很多東西筆者現(xiàn)在還不能理解,也沒有用到,先挑筆者理解的進(jìn)行解釋。
第一條:提供軟件包名。這就是我們的apk的名字,通常我們的名字都是類似"com.android.gles3jni"這種,和Java類名類似,目的是確定使其成為一個(gè)唯一值。
第二條:描述應(yīng)用的各個(gè)組件。這是用來定義四大組件用的。我們最常用的就是Activity組件。它需要定義組件的表現(xiàn)形式(組件名、主題、啟動(dòng)類型),組件可以響應(yīng)的操作(例如某個(gè)啟動(dòng)意圖)等。
第三條、第四條和第五條:還沒用到,不做解釋。
第五條:聲明最低API級(jí)別。這個(gè)級(jí)別在build.gradle文件中也能定義,字段是minSdkVersion。在AndroidManifest.xml文件中定義的情況比較少。
第六條:列出必要的lib庫。這東西在3.0以后的Android Studio似乎也沒什么功能,因?yàn)樵?.0以后編譯用的是CMakeLists.txt文件,以及build.gradle文件來指定庫。
接下來接介紹android studio 清單配置文件androidmainfest.xml解讀。
1、注冊(cè)Activity頁面,并指定首頁。
所有的頁面文件要在此文件中注冊(cè)。
指定是APP的首頁:(android:exported="true")和下面的 intent-filter中的兩行,;

2、需要的權(quán)限要在此文件中指定;
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- Needed only if your app looks for Bluetooth devices.
If your app doesn't use Bluetooth scan results to derive physical
location information, you can
<a href="#assert-never-for-location" rel="external nofollow" >strongly assert that your app
doesn't derive physical location</a>. -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Needed only if your app makes the device discoverable to Bluetooth
devices. -->
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<!-- Needed only if your app communicates with already-paired Bluetooth
devices. -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.LabelPrint"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>到此這篇關(guān)于android studio 清單配置文件androidmainfest.xml解讀的文章就介紹到這了,更多相關(guān)androidmainfest.xml解讀內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android TabLayout 實(shí)現(xiàn)底部Tab的示例代碼
本篇文章主要介紹了Android TabLayout 實(shí)現(xiàn)底部Tab的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-01-01
Android使用觀察者模式Observer實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)監(jiān)聽
這篇文章主要為大家詳細(xì)介紹了Android使用觀察者模式Observer實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)監(jiān)聽,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
詳解android特性之CoordinatorLayout用法探析實(shí)例
本篇文章主要介紹了android特性之CoordinatorLayout用法探析實(shí)例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-02-02
Android字體大小自適應(yīng)不同分辨率的解決辦法
這篇文章主要介紹了Android字體大小自適應(yīng)不同分辨率的解決辦法的相關(guān)資料,需要的朋友可以參考下2017-06-06
Android中 動(dòng)態(tài)改變對(duì)話框值的方法
Android Dev-Guide 推薦重寫Activity.onCreateDialog()方法來創(chuàng)建Dialog,這樣Dialog就歸屬于這個(gè)Activity了。2013-04-04
Android TraceView和Lint使用詳解及性能優(yōu)化
這篇文章主要介紹了Android TraceView和Lint使用詳解及性能優(yōu)化的相關(guān)資料,需要的朋友可以參考下2017-03-03
Android studio 項(xiàng)目手動(dòng)在本地磁盤中刪除module后,殘留文件夾無法刪除的問題解決方法
這篇文章主要介紹了Android studio 項(xiàng)目手動(dòng)在本地磁盤中刪除module后,殘留文件夾無法刪除問題,本文給出了解決方法,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03

