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文件的更多相关文章

  1. [转]AndroidManifest.xml文件详解

    转自:http://www.cnblogs.com/greatverve/archive/2012/05/08/AndroidManifest-xml.html AndroidManifest.xml ...

  2. android基础知识13:AndroidManifest.xml文件解析

    注:本文转载于:http://blog.csdn.net/xianming01/article/details/7526987 AndroidManifest.xml文件解析. 1.重要性 Andro ...

  3. [安卓学习]AndroidManifest.xml文件内容详解

    一,重要性 AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根 ...

  4. AndroidManifest.xml文件综合详解(转)

    一,重要性AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根目 ...

  5. Android之AndroidManifest.xml文件解析

    转自:Android学习笔记之AndroidManifest.xml文件解析 一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文 ...

  6. AndroidManifest.xml文件详解(uses-permission)

    语法(SYNTAX): <uses-permissionandroid:name="string"/> 被包含于(CONTAINED IN): <manifest ...

  7. [安卓]AndroidManifest.xml文件简介及结构

    1.AndroidManifest.xml文件简介: 每个应用程序在它的根目录中都必须要有一个AndroidManifest.xml(名字须精确一致)文件.这个清单把应用程序的基本信息提交给Andro ...

  8. Android Studio 学习 - AndroidManifest.xml文件学习

    首先,今天发现了一个很牛逼的教程网站:慕课网(http://www.imooc.com/).有很多大牛发布的教学视频.值得收藏.学习. 今天主要参照陈启超老大的视频,学习了多个Activity之间的切 ...

  9. 查看 AndroidManifest.xml文件

    1.Manifest Explorer 装在Android手机中,用此apk看系统中已安装应用的AndroidManifest.xml文件: protected boolean configForPa ...

随机推荐

  1. 先知xss挑战赛学习笔记

    xss游戏 游戏地址:http://ec2-13-58-146-2.us-east-2.compute.amazonaws.com/ LEMON参考wp地址 1. 文件上传 源码如下 <?php ...

  2. Arthas之类操作

    Arthas之类操作 1. classLoader 查询当前JVM中存在的classloader classloader name numberOfInstances loadedCountTotal ...

  3. 简述在 MySQL 数据库中 MyISAM 和 InnoDB 的区别 ?

    MyISAM: 第 134 页 共 485 页不支持事务,但是每次查询都是原子的: 支持表级锁,即每次操作是对整个表加锁: 存储表的总行数: 一个 MYISAM 表有三个文件:索引文件.表结构文件.数 ...

  4. 深入理解Java虚拟机-垃圾收集算法

    一.判断对象是否可进行回收 1.引用计数算法 给对象中添加一个引用计数器,每当有一个地方引用它时,计数器值就加1:当引用失效时,计数器值就减1:任何时刻计数器为0的对象就是不可能再被使用的.但是主流的 ...

  5. web.xml---配置文件概要

    web.xml分发器: case1: springMvc的分发器: 作用:将匹配上的请求交由springMvc处理,路径会继续到达springMvc的处理器映射器 <servlet> &l ...

  6. volatile 能使得一个非原子操作变成原子操作吗?

    一个典型的例子是在类中有一个 long 类型的成员变量.如果你知道该成员变量 会被多个线程访问,如计数器.价格等,你最好是将其设置为 volatile.为什么? 因为 Java 中读取 long 类型 ...

  7. 初识Spring(为什么要使用Spring?)

    Spring,英文翻译是春天的意思,而在Java中,是一个开放源代码的设计层面框架(手动滑稽,程序员的春天),他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用.S ...

  8. ACM中的位运算技巧

    听说位运算挺好玩的,那这节总结一下ACM中可能用到的位运算技巧. XOR运算极为重要!!(过[LC136](只出现一次的数字 - 力扣(LeetCode)):数组中每个数字都出现两次,只有一个出现一次 ...

  9. 3. Git安装和使用

    3. Git安装和使用 目的 通过git管理github托管项目代码 下载安装 1)GIt官网下载:https://www.git-scm.com/download/win 2)双击安装 3)选择安装 ...

  10. C语言杂谈

    C语言程序处理过程 预处理:宏定义展开.头文件展开.条件编译,这里并不会检查语法 编译:检查语法,将预处理后文件编译生成汇编文件 汇编:将汇编文件生成目标文件(二进制文件) 链接:将目标文件链接为可执 ...