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( ...
随机推荐
- Linux下yum升级安装PHP 5.5
我的系统是Centos 6.5 ,安装lnmp是直接yum安装的,php版本为5.4的,当安装了最新的phpMyAdmin(4.5.1)数据库管理软件后发现不支持php5.4使用,所以只好升级下php ...
- protocol buffers的使用示例[z]
[http://blog.csdn.net/zhu_xun/article/details/19397081] protocol buffers的使用示例 如果不了解protocol buffers, ...
- 洛谷P1738 洛谷的文件夹
原题目:点我 题目是一个略水的题,我机制地用面向对象做了...所以代码量急剧加大,100行233 模拟即可,字符串处理麻烦点.如果没有找到子文件夹就新建文件夹,如果有就进入该文件夹. 提示:高能,指针 ...
- idhttp的用法
1)POST function PostMethod(http: TIDhttp; URL: string; Params: TStringList): string;var RespData: TS ...
- python 异常含义
异常 描述 NameError 尝试访问一个没有申明的变量 ZeroDivisionError 除数为0 SyntaxError 语法错误 IndexError 索引超出序列范围 KeyError 请 ...
- 开始学CI
未来一段时间的学习计划 1.codeIgniter 2.angular JS 深入 3.react 4.python 边工作边学习,保持进步
- 让linux中的程序崩溃时生成core文件
当我们的linux程序崩溃的时候,常常会有这样的提示: Segmentation fault (core dumped) 段错误 (核心已转储) 提示说生成了core文件,但是此功能 ...
- mysql Blob存取的一个简单例子
一.得到mysql的连接 这里封装成一个方法,方便后面使用. public Connection getConnection() throws Exception{ String url = &quo ...
- inotify 心得
inotify 心得 一.inotify简介 inotify是Linux内核2.6.13 (June 18, 2005)版本新增的一个子系统(API),它提供了一种监控文件系统(基于inode的)事件 ...
- 分享MYSQL中的各种高可用技术(源自姜承尧大牛)
分享MYSQL中的各种高可用技术(源自姜承尧大牛) 图片和资料来源于MYSQL大牛姜承尧老师(MYSQL技术内幕作者) 姜承尧: 网易杭州研究院 技术经理 主导INNOSQL的开发 mysql高可用各 ...