AndroidManifest常见的设置解析
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常见的设置解析的更多相关文章
- 一文读懂四种常见的XML解析技术
之前的文章我们讲解了<XML系列教程之Schema技术_上海尚学堂java培训技术干货><XML的概念.特点与作用.XML申明_上海Java培训技术干货>,大家可以点击回顾一下 ...
- Web安全测试中常见逻辑漏洞解析(实战篇)
Web安全测试中常见逻辑漏洞解析(实战篇) 简要: 越权漏洞是比较常见的漏洞类型,越权漏洞可以理解为,一个正常的用户A通常只能够对自己的一些信息进行增删改查,但是由于程序员的一时疏忽,对信息进行增删改 ...
- 转:YUV RGB 常见视频格式解析
转: http://www.cnblogs.com/qinjunni/archive/2012/02/23/2364446.html YUV RGB 常见视频格式解析 I420是YUV格式的一种,而Y ...
- SQL点滴26—常见T-SQL面试解析
原文:SQL点滴26-常见T-SQL面试解析 它山之石可以攻玉,这一篇是读别人的博客后写下的,不是原原本本的转载,加入了自己的分析过程和演练.sql语句可以解决很多的复杂业务,避免过多的项目代码,下面 ...
- python常见排序算法解析
python——常见排序算法解析 算法是程序员的灵魂. 下面的博文是我整理的感觉还不错的算法实现 原理的理解是最重要的,我会常回来看看,并坚持每天刷leetcode 本篇主要实现九(八)大排序算法 ...
- java中常见的json解析方法、库以及性能对比
常见的json解析有原生的JSONObject和JSONArray方法,谷歌的GSON库,阿里的fastjson,还有jackson,json-lib. Gson(项目地址:https://githu ...
- 深入理解java虚拟机笔记补充-JVM常见参数设置
JVM 常见参数设置 内存设置 参数 -Xms:初始堆大小,JVM 启动的时候,给定堆空间大小. -Xmx:最大堆大小,如果初始堆空间不足的时候,最大可以扩展到多少. -Xmn:设置年轻代大小.整个堆 ...
- android AndroidManifest.xml 属性详细解析
一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(activiti ...
- PHP中常见魔术方法解析
<?php class info { private $province; //省 public $city; //城市 private $myname; //姓名 //__construct( ...
随机推荐
- java 抽象类与接口的区别
在Java 语言中, abstract class 和interface 是支持抽象类 定义的两种机制.正是由于这两种机制的存在,才赋予 了Java强大的 面向对象能力.abstract class和 ...
- Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 'XXX'.
Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 'XXX'. ...
- 咏南CS插件开发框架也可BS方式部署
在几分钟的时间内,CS客户端也可以BS方式部署.
- python 高阶函数与装饰器
高阶函数定义1.函数接收的参数是一个函数名2.函数的返回值是一个函数名以上两者满足任意一个,就是高阶函数装饰器定义本质就是函数,功能是为其他函数添加新功能 装饰器的原则 1.不修改被装饰函数的源代码( ...
- iframe空文档中写入内容
往一个空的iframe中写入内容,再其document ready之前有可能遇到拿回 的body指针为空,因此以下面的函数往其document中写入html HRESULT WriteToHtmlDo ...
- tomcat 支持ssi功能配置
1.SSI是Server Side Includes 的缩写,是嵌入到HTML页面的一组指令的集合.在返回请求的页面(包含SSI指令前),服务器会处理这些指令,并用处理的结果替换指令,然后把页面返回. ...
- [转贴]有关Angular 2.0的一切
对Angular 2.0的策略有疑问吗?就在这里提吧.在接下来的这篇文章里,我会解释Angular 2.0的主要特性区域,以及每个变化背后的动机.每个部分之后,我将提供自己在设计过程中的意见和见解,包 ...
- DP专题——括号序列
毕竟是个渣,写完一遍之后又按LRJ的写了一遍,再写了一遍递归版,最终加上输出解部分 括号序列 定义如下规则序列(字符串): 空序列是规则序列: 如果S是规则序列,那么(S)和[S]也是规则序列: 如果 ...
- 在NopCommerce中启用MiniProfiler
MVC MiniProfiler是Stack Overflow团队设计的一款对ASP.NET MVC.WebForm 以及WCF 的性能分析的小程序.可以对一个页面本身,及该页面通过直接引用.Ajax ...
- C++中复制构造函数
复制构造函数 复制构造函数用于: 根据另一个同类型的对象显示或隐式初始化一个对象 复制一个对象,将它作为实参传给一个函数 从函数返回时复制一个对象 初始化顺序容器中的元素 根据元素初始化式列表初始化数 ...