AndroidManifest.xml清单文件是每个Android项目所必需的,它是整个Android项目的全局描述文件。AndroidManifest.xml清单文件说明了该应用的名称、所使用的图标以及包含的组件等。

  AndroidManifest.xml清单文件通常包含如下信息:

  ->应用程序的包名,该包名将会作为该应用的唯一标识。

  ->应用程序所包含的组件,如Activity、Service、BroadcastReceiver和Content Provider等。

  ->应用程序兼容的最低版本。

  ->应用程序使用系统所需的权限声明。

  ->其他程序访问该程序所需的权限声明。

1)例子1:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<!--应用程序唯一包名-->
package="com.example.proposalundertake"
<!--应用程序版本号、版本名称-->
android:versionCode="1"
android:versionName="@string/versionName" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" /> <!--声明应用所需要的权限-->
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" /> <application
<!--应用程序初始化装载的全局Application-->
android:name="com.example.proposalundertake.MyApplication"
android:allowBackup="true"
<!--应用程序图标、应用程序名称、应用程序主题-->
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" > <!-- 百度key绑定 -->
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="7YHo2b38vOheODLzlpUxRdmn"
/> <!--service声明-->
<service android:name="com.example.proposalundertake.service.ClientKernelService" android:exported="false">
<intent-filter>
<action android:name="com.example.proposalundertake.service.ClientKernelService" >
</action>
</intent-filter>
</service> <service android:name="com.example.proposalundertake.bpgmsg.BPGMsgService" android:exported="false">
<intent-filter>
<action android:name="com.example.proposalundertake.bpgmsg.BPGMsgService" />
</intent-filter>
</service> <!-- 欢迎界面0,允许其他程序调用打开该页面-->
<activity
android:name="com.example.proposalundertake.activity.InitActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme = "@style/Transparent"
>
<intent-filter>
<action android:name="com.example.proposalundertake.activity.MYACTION" />
<data android:scheme="info"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> <!-- 欢迎界面,默认主程序启动页面-->
<activity
android:name="com.example.proposalundertake.activity.LoginActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <!-- 登录中的更新handler用到的类 -->
<activity
android:name="com.example.proposalundertake.activity.ClientOnTopMessageBox"
android:label="@string/bill_app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.OnTopDialog"
<!--该页面下软键盘的显示、隐藏形式-->
android:windowSoftInputMode="stateHidden|adjustPan" >
</activity>
</application>
</manifest>

这里浅谈一下service,其中com.example.proposalundertake.service.ClientKernelService,是自定义继承Service的服务,重写其中的onCreate(),onBind(),

,onUnbind(),onDestroy()等(其中,Service的声明周期只继承了onCreate(),onStart(),onDestroy()三个方法)。

可以通过Intent来启动service:

 Intent = new Intent("com.example.proposalundertake.service.ClientKernelService");
Bundle bundle = new Bundle();
bundle.putInt("open",1);
intent.putExtras(bundle);
startService(intent);

另外,其中com.example.proposalundertake.activity.InitActivity,类别标记为android.intent.category.DEFAULT,也就是可以允许其他程序调用:

 // 需要使用Intent类的第2个参数指定Uri
Intent intent = new Intent(
"com.example.proposalundertake.activity.MYACTION",
Uri.parse("info://调用主程序的Activity"));
// 传递6个参数
String ip = LoginActivity.this.getResources().getString(
R.string.heyuan_ip);
String passwordtype = LoginActivity.this.getResources()
.getString(R.string.password_type);
String appname = LoginActivity.this.getResources()
.getString(R.string.app_name); intent.putExtra("ip", ip);
intent.putExtra("username", username);
intent.putExtra("password", password);
intent.putExtra("passwordtype", passwordtype); // 服务端加密类型MD5 或 明码等
intent.putExtra("appname", appname); // 主程序应用名称
intent.putExtra("appname_small", appname_small);
startActivity(intent);

2)例子2:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.proposalbill_hy_lead"
android:versionCode="1"
android:versionName="@string/versionName" > <uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" /> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.proposalbill_hy_lead.WelcomeActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity
android:name="com.example.proposalbill_hy_lead.LoginActivity"
android:windowSoftInputMode="stateHidden|adjustPan"
android:screenOrientation="portrait"
></activity> <receiver
android:name="com.example.proposalbill_hy_lead.TestReceiver2">
<intent-filter>
<action android:name="com.example.proposalbill.lead"/>
</intent-filter>
</receiver>
</application>
</manifest>

其中AndroidManifest声明了BroadcastRecevier,com.example.proposalbill_hy_lead.TestReceiver2为继承BroadcastReceiver的类,重写onReceive方法,可以

处理接收到广播后的动作(如,弹出提示、请求网络数据、结束应用自身等等):

 //发送广播,子程序接收广播,结束子程序的登录页面
Intent intent = new Intent();
intent.setAction("com.example.proposalbill.lead");
intent.putExtra("msg", ConstantUtil.appname_small); //对应要结束的子程序
sendBroadcast(intent);

AndroidManifest常见的设置解析的更多相关文章

  1. 一文读懂四种常见的XML解析技术

    之前的文章我们讲解了<XML系列教程之Schema技术_上海尚学堂java培训技术干货><XML的概念.特点与作用.XML申明_上海Java培训技术干货>,大家可以点击回顾一下 ...

  2. Web安全测试中常见逻辑漏洞解析(实战篇)

    Web安全测试中常见逻辑漏洞解析(实战篇) 简要: 越权漏洞是比较常见的漏洞类型,越权漏洞可以理解为,一个正常的用户A通常只能够对自己的一些信息进行增删改查,但是由于程序员的一时疏忽,对信息进行增删改 ...

  3. 转:YUV RGB 常见视频格式解析

    转: http://www.cnblogs.com/qinjunni/archive/2012/02/23/2364446.html YUV RGB 常见视频格式解析 I420是YUV格式的一种,而Y ...

  4. SQL点滴26—常见T-SQL面试解析

    原文:SQL点滴26-常见T-SQL面试解析 它山之石可以攻玉,这一篇是读别人的博客后写下的,不是原原本本的转载,加入了自己的分析过程和演练.sql语句可以解决很多的复杂业务,避免过多的项目代码,下面 ...

  5. python常见排序算法解析

    python——常见排序算法解析   算法是程序员的灵魂. 下面的博文是我整理的感觉还不错的算法实现 原理的理解是最重要的,我会常回来看看,并坚持每天刷leetcode 本篇主要实现九(八)大排序算法 ...

  6. java中常见的json解析方法、库以及性能对比

    常见的json解析有原生的JSONObject和JSONArray方法,谷歌的GSON库,阿里的fastjson,还有jackson,json-lib. Gson(项目地址:https://githu ...

  7. 深入理解java虚拟机笔记补充-JVM常见参数设置

    JVM 常见参数设置 内存设置 参数 -Xms:初始堆大小,JVM 启动的时候,给定堆空间大小. -Xmx:最大堆大小,如果初始堆空间不足的时候,最大可以扩展到多少. -Xmn:设置年轻代大小.整个堆 ...

  8. android AndroidManifest.xml 属性详细解析

    一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(activiti ...

  9. PHP中常见魔术方法解析

    <?php class info { private $province; //省 public $city; //城市 private $myname; //姓名 //__construct( ...

随机推荐

  1. java内存分析

    链接:http://blog.csdn.net/chana1101/article/details/5632393

  2. IOS线程的一些总结

    主线程的作用 (在主线程中才能设置) 显示/刷新UI界面 处理UI事件(比如点击事件.滚动事件.拖拽事件): 主线程的使用注意 别将比较耗时的操作放到主线程中. 耗时操作会卡住主线程.影响体验. [N ...

  3. 。net 添加或获取文件关联

    文件关联设置 2011-02-07 14:25:36|  分类: VB.net2008或2010 |  标签:文件关联  |举报|字号 订阅     原理:以后缀名为.txt为例 方式一: 1.在注册 ...

  4. 参数(parameter)和属性(Attribute)的区别

    参数(parameter)和属性(Attribute)的区别 区别: 来源不同: 参数(parameter)是从客户端(浏览器)中由用户提供的,若是GET方法是从URL中 提供的,若是POST方法是从 ...

  5. MongoDB介绍与windows下安装

    MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类 似json的bjson格式,因此可以存储比较复杂的数据类型. ...

  6. ubuntu 14.04下 horizon openstack_dashboard 的开发环境搭建

    序:公司要在openstack的基础上,做开发做产品,网上资料也不是很多,很多都是在来回copy,在此做个blog,慢慢更新,推动自己进步. 首先老话题:开发环境的搭建.     一个纯净的ubunt ...

  7. Postman-简单使用

    Postman-简单使用 Postman-进阶使用 Postman-CI集成Jenkins Postman功能(https://www.getpostman.com/features) 主要用于模拟网 ...

  8. (原创)基于FPGA的调光流水灯(Verilog,CPLD/FPGA)

    1.Abstract     前几天做了一个呼吸灯,觉得确实挺有意思的:可惜的是只有一个灯管亮,板子上有四个灯,要是能让这些灯有序地亮起来,那应该更有趣味了!跟传统的一样,逻辑上做成一个流水灯的样式, ...

  9. linux基本命令--学习记录

    1.mkdir -p 递归创建目录(-p参数代表递归创建): 2.touch 创建file: 3.cat 查看 5.vi 编辑器 6.echo >(直接覆盖) 或者<<(后面追加)单 ...

  10. C#执行OracleHelper

    /// <summary> /// 执行存储过程获取带有Out的参数 /// </summary> /// <param name="cmdText" ...