简单了解AndroidManifest.xml文件
AndroidManifest.xml:资源清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.java.activitytest">
<!-- 允许联网 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 获取GSM(2g)、WCDMA(联通3g)等网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 获取wifi网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 保持CPU 运转,屏幕和键盘灯有可能是关闭的,用于文件上传和下载 -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 获取sd卡写的权限,用于文件上传和下载 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 允许读取手机状态 用于创建BmobInstallation -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!--视频播放权限-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".ResultActivity">
</activity>
<activity
android:name=".QuestionActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/NoActionBarTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application> </manifest>
android:allowBackup="true" ==> 允许备份
android:icon ==> 应用图标
android:label ==> 应用名称
android:supportsRtl ==> 支持从右到左布局
android:theme ==> 主题
进入主题看看:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">指定主题为:不带ActinBar的浅色主题。
不带ActionBar的主题通常有两种:"Theme.AppCompat.Light.NoActionBar" 和 "Theme.AppCompat.NoActionBar" 前者表示浅色主题,后者表示深色主题。
<item name="colorPrimary">@color/colorPrimary</item> 是为colorPrimary属性指定颜色。
下图为各属性指定颜色的位置:

回到清单文件的<activity android:name=".ResultActivity"> </activity> 是对ResultActivity的注册。(四大组件都需要注册)
所有的Activity都要在AndroidManifest.xml文件中注册才能生效,每次创建新的Activity时,AndroidStudio会自动帮我们注册。
使用android:name来指定具体注册哪一个Activity,这里的.ResultActivity是com.java.activitytest.ResultActivity的缩写。
由于在最外层的<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.java.activitytest"> 标签中已经通过package属性指定了程序的包名是com.java.activitytest,因此在注册Activity时,这一部分可以省略,直接使用.ResultActivity就可以了。
android:screenOrientation ==>用于控制activity启动时方向
可以取值:
landscape:限制界面为横屏,旋转屏幕也不会改变当前状态。
portrait:限制界面为竖屏,旋转屏幕也不会改变当前状态。
sensor:根据传感器定位方向,旋转手机90度,180,270,360,界面都会发生变化。
sensorLandscape:(横屏的旋转,不会出现竖屏的现象)根据传感器定位方向,旋转手机180度界面旋转。一般横屏游戏会是这个属性。
sensorPortrait:(竖屏的旋转,不会出现横屏的现象)根据传感器定位方向,旋转手机180度界面会旋转。
unspecified:由系统选择显示方向,不同的设备可能会有所不同。(旋转手机,界面会跟着旋转)
user:用户当前的首选方向。
nosensor:不由传感器确定方向。旋转设备的时候,界面不会跟着旋转。初始界面方向由系统提供。
android:windowSoftInputMode ==> 设置窗口软键盘的交互模式为adjustResize :该Activity总是调整屏幕的大小以便留出软键盘的空间
再看<intent-filter> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> </intent-filter>,为程序配置主Activity。
在android里一个应用程序可以有多个入口。如下所示:
1.创建两个Activity
2.设置清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kotlin.activitystudy">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ActivityStudy">
<activity android:name=".MainActivity2"
android:label="第二个">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="第一个">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这里将两个Activity都设置成了主程序,程序运行时会按照顺序优先显示MainActivity2
3.设置布局文件
在两个布局文件里各放了一个TextView
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是第一个入口!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout>
activity_main2.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是第二个入口!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
4.启动模拟器
启动后会产生两个程序入口
点进第一个:

点进第二个:

若出现点进去的内容一样,需要在后台杀死程序,再重新进入
简单了解AndroidManifest.xml文件的更多相关文章
- [转]AndroidManifest.xml文件详解
转自:http://www.cnblogs.com/greatverve/archive/2012/05/08/AndroidManifest-xml.html AndroidManifest.xml ...
- android基础知识13:AndroidManifest.xml文件解析
注:本文转载于:http://blog.csdn.net/xianming01/article/details/7526987 AndroidManifest.xml文件解析. 1.重要性 Andro ...
- [安卓学习]AndroidManifest.xml文件内容详解
一,重要性 AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根 ...
- AndroidManifest.xml文件综合详解(转)
一,重要性AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根目 ...
- Android之AndroidManifest.xml文件解析
转自:Android学习笔记之AndroidManifest.xml文件解析 一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文 ...
- AndroidManifest.xml文件详解(uses-permission)
语法(SYNTAX): <uses-permissionandroid:name="string"/> 被包含于(CONTAINED IN): <manifest ...
- [安卓]AndroidManifest.xml文件简介及结构
1.AndroidManifest.xml文件简介: 每个应用程序在它的根目录中都必须要有一个AndroidManifest.xml(名字须精确一致)文件.这个清单把应用程序的基本信息提交给Andro ...
- Android Studio 学习 - AndroidManifest.xml文件学习
首先,今天发现了一个很牛逼的教程网站:慕课网(http://www.imooc.com/).有很多大牛发布的教学视频.值得收藏.学习. 今天主要参照陈启超老大的视频,学习了多个Activity之间的切 ...
- 查看 AndroidManifest.xml文件
1.Manifest Explorer 装在Android手机中,用此apk看系统中已安装应用的AndroidManifest.xml文件: protected boolean configForPa ...
随机推荐
- json.dumps参数之解
宝藏参数,懂的都懂^-^ 说明:编译后print()打印内容,此内容以字符串紧凑输出,且无顺序,中文不可读.. 应用:使用pycharm做接口测试时,print()打印出的接口下行,如下图: ...
- Spring核心思想:IOC(控制反转)、DI(依赖注入)和AOP(面向切面编程)
Spring有三大核心思想,分别是控制反转(IOC,Inversion Of Controller),依赖注入(DI,Dependency Injection)和面向切面编程(AOP,Aspect O ...
- 对象头源码讲解,原来,指向objectMonitor的指针在这里
markword 注释 该文件目录在: \openjdk-jdk8u\hotspot\src\share\vm\oops\markOop.hpp #ifndef SHARE_VM_OOPS_MARKO ...
- Java 中的 TreeMap 是采用什么树实现的?
Java 中的 TreeMap 是使用红黑树实现的.
- 学习Solr(一)
一.安装 1.需要的安装包:apache-tomcat-7.0.47.tar.gz.solr-4.10.3.tgz.tgz(jdk自行安装) 2.解压tomcat并创建solr文件夹 [root@lo ...
- 顺利通过EMC实验(17)
- 顺利通过EMC试验(2)
限制值 电磁波照射,静电放电敏感性
- Vue中获取元素宽高
<div ref="init"></div> 写在 页面 方法 部分 这里的 offsetHeight 是返回元素的宽度(包括元素宽度.内边距和边框,不包括 ...
- H5打造属于自己的视频播放器(JS篇2)
回顾 算了不回顾了 直接搞起,打开JS1中写的bvd.js 播放视频 播放按钮隐藏 视频开始播放 当点击播放按钮的时候,播放按钮将会隐藏,播放视频,这个不难,在JS1中我们就已经实现.但我们改变一下思 ...
- 微信小程序&mpvue问题总结(1)
微信小程序进入到首页的时候,日志打印出"created", "onlaunch", "mounted",具体代码如下:那么,在小程序中 cr ...

