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( ...
随机推荐
- JVM调优-Java中的对象
Java对象的大小 基本数据的类型的大小是固定的,这里不做详细说明.对于非基本类型的Java对象,其大小就值得商榷. 在Java中,一个空Object对象的大小是8byte,这个大小只是保存堆中一个没 ...
- poj练习题的方法
poj1010--邮票问题 DFSpoj1011--Sticks dfs + 剪枝poj1020--拼蛋糕poj1054--The Troublesome Frogpoj1062--昂贵的聘礼poj1 ...
- linux下如何开启oracle服务和开启监听
su - oracle 切换到oracle用户模式下 sqlplus /nolog //登录sqlplus SQL> connect /as sysdba //连接oracle SQL&g ...
- CSS3中:nth-child和:nth-of-type的区别深入理解
关于:nth-child和:nth-of-type的区别之前一直没太注意.最近打算深入了解一些CSS3,才发现里面其实暗藏玄机. :nth-child可以选择父元素下的字元素,:nth-of-type ...
- Spring MVC+Spring +Hibernate配置事务,但是事务不起作用
最近做项目,被一个问题烦恼了很久.使用Spring MVC+Spring +Hibernate开发项目,在使用注解配置事务管理,刚开始发现无论如何数据库都无法更新,但是可以从数据库查询到数据.怀疑是配 ...
- java 类的关系
在面向对象中,类与类之间的关系有泛化,依赖,关联,聚合,组合几种.其中,聚合和组合都属于关联.在具体编程中: 依赖表现为如果A类依赖于B,则B体现为A的局部变量,方法参数或静态方法的调用.eg:cla ...
- Maven项目配置不接文件名
1.更改finalName为ROOT,在pom.xml中加入下边的build,是可以进行自动启动Tomcat. 2.删除webapps目录下的ROOT文件夹 3.进行maven项目的deploy 4. ...
- 1.1 Activity
1.概念 Application:由多个相关的松散的与用户进行交互Activity组成,通常被打包成apk后缀文件中: Activity:就是被用来进行与用户交互和用来与android内部特性交互的组 ...
- Linux开启关闭redis
1.启动:redis-server(redis-server redis.conf) 2.登陆:redis-cli(redis-cli -p 6379) 3.关闭:redis-cli shutdown
- python文件选择:tkFileDialog 基础
tkFileDialog有两种形式: 一个是.askopenfilename(option=value, ...) 这个是"打开"对话框 另一个是:asksaveasfilenam ...