欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android studio 清單配置文件androidmainfest.xml詳細解讀

 更新時間:2024年04月12日 09:23:01   作者:一貼靈  
AndroidManifest官方解釋是應用清單,每個應用的根目錄中都必須包含一個,并且文件名必須一模一樣,這個文件中包含了APP的配置信息,系統(tǒng)需要根據(jù)里面的內(nèi)容運行APP的代碼,顯示界面,這篇文章介紹了android studio 清單配置文件androidmainfest.xml解讀,需要的朋友可以參考下

AndroidManifest是什么?

AndroidManifest官方解釋是應用清單(manifest意思是貨單),每個應用的根目錄中都必須包含一個,并且文件名必須一模一樣。這個文件中包含了APP的配置信息,系統(tǒng)需要根據(jù)里面的內(nèi)容運行APP的代碼,顯示界面。

AndroidManifest的作用是什么?

上述的功能是非常籠統(tǒng)的解釋,具體到細節(jié)就是:

  • 為應用的 Java 軟件包命名。軟件包名稱充當應用的唯一標識符。
  • 描述應用的各個組件,包括構(gòu)成應用的 Activity、服務、廣播接收器和內(nèi)容提供程序。它還為實現(xiàn)每個組件的類命名并發(fā)布其功能,例如它們可以處理的 Intent 消息。這些聲明向 Android 系統(tǒng)告知有關(guān)組件以及可以啟動這些組件的條件的信息。
  • 確定托管應用組件的進程。
  • 聲明應用必須具備哪些權(quán)限才能訪問 API 中受保護的部分并與其他應用交互。還聲明其他應用與該應用組件交互所需具備的權(quán)限
  • 列出 Instrumentation類,這些類可在應用運行時提供分析和其他信息。這些聲明只會在應用處于開發(fā)階段時出現(xiàn)在清單中,在應用發(fā)布之前將移除。
  • 聲明應用所需的最低 Android API 級別
  • 列出應用必須鏈接到的庫

上面是官方的解釋。很多東西筆者現(xiàn)在還不能理解,也沒有用到,先挑筆者理解的進行解釋。

  • 第一條:提供軟件包名。這就是我們的apk的名字,通常我們的名字都是類似"com.android.gles3jni"這種,和Java類名類似,目的是確定使其成為一個唯一值。

  • 第二條:描述應用的各個組件。這是用來定義四大組件用的。我們最常用的就是Activity組件。它需要定義組件的表現(xiàn)形式(組件名、主題、啟動類型),組件可以響應的操作(例如某個啟動意圖)等。

  • 第三條、第四條和第五條:還沒用到,不做解釋。

  • 第五條:聲明最低API級別。這個級別在build.gradle文件中也能定義,字段是minSdkVersion。在AndroidManifest.xml文件中定義的情況比較少。

  • 第六條:列出必要的lib庫。這東西在3.0以后的Android Studio似乎也沒什么功能,因為在3.0以后編譯用的是CMakeLists.txt文件,以及build.gradle文件來指定庫。

接下來接介紹android studio 清單配置文件androidmainfest.xml解讀。

1、注冊Activity頁面,并指定首頁。

  所有的頁面文件要在此文件中注冊。

  指定是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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論