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. First Note

    第一篇博客 入驻博客园.

  2. Spring Boot 2.X 有什么新特性?与 1.X 有什么区别?

    配置变更JDK 版本升级第三方类库升级响应式 Spring 编程支持HTTP/2 支持配置属性绑定更多改进与加强-

  3. jQuery对象的创建

    1.js类库 JavaScript封装了很多的预定义的对象和实用函数,能帮助使用者建立有高难度交互 客户端页面,并且兼容各大浏览器.跑在浏览器,请求服务器 当前比较流行的js库: jquery EXT ...

  4. 为什么 wait, notify 和 notifyAll 这些方法不在 thread 类里面?

    一个很明显的原因是 JAVA 提供的锁是对象级的而不是线程级的,每个对象都有 锁,通过线程获得.由于 wait,notify 和 notifyAll 都是锁级别的操作,所以把他 们定义在 Object ...

  5. 学习MFS(一)

    MFS概述 MooseFS,是一个具备冗余容错功能的分布式网络文件系统,它将数据分别存放在多个物理server或单独disk或partition上,确保一份数据有多个备份副本,对于访问MFS的clie ...

  6. 顺利通过EMC实验(17)

  7. Altium design使用日常故障总结

    1.altiumdesigner09如何将不同的板子拼在一起发给工厂?打开这两个图,其中一个图ctrl+a,ctrl+c,打开另一个图pastespecial.放置时选取一边对齐.制版时告诉厂家做个V ...

  8. layui表单使用开关滑块和复选框,渲染后台数据方法

    提示:整个表格要在form标签内 定义开关模板 <div class="layui-form" lay-filter="layuiadmin-app-form-li ...

  9. translate3d 对 z-index 居然有影响

    在 Mobile 端需要注意. 安卓 默认浏览器 当中如果 div1 div2 如果 div1 有 translate3d 而 div2 没有 那么 div2 的 z-index 会无效. 解决办法: ...

  10. 小白上学のcanvas零基础

    <canvas> 元素 <canvas> 看起来和 <img> 元素很相像,唯一的不同就是它并没有 src 和 alt 属性.实际上,<canvas> ...