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( ...
随机推荐
- Python学习笔记- Python threading模块
Python threading模块 直接调用 # !/usr/bin/env python # -*- coding:utf-8 -*- import threading import time d ...
- 编写出色的GNU/Linux程序
http://advancedlinuxprogramming.com提供了本书电子版的免费下载. 1 与执行环境交互 关于参数 C语言程序的main()函数使用两个参数和执行环境交互--(int)a ...
- listView获取item的Edit内容,listView中的edit内容在滚动时自动赋值了前面的内容
Today I am going to explain how to create a ListView with EditText and why will we need a TextWatche ...
- net SqlBulkCopy拷贝数据的问题
服务器配置:windows 2008 ,sql server 2008, oracle 10g. 在本地和同样配置的其他服务器上同样的程序,数据200万都很快就采集过来了,但是在发布的服务器上,如果b ...
- window.open打开窗体和if嵌套
<script> function openWindow(){var my=confirm("你要打开窗口吗?")if(my==true){ var url ...
- LeetCode OJ-- Valid Number **@
https://oj.leetcode.com/problems/valid-number/ 判断给的串,是不是合理的 数字形式 主要问题在需求定义上吧 class Solution { public ...
- Unity3D 中 用quaternion 来对一个坐标点进行旋转的初步体会
在unity3d中,用四元数来表示旋转,四元数英文名叫quaternion . 比如 transform.rotation 就是一个四元数,其由四个部分组成 Quaternion = (xi + yj ...
- Java 第14章 字符串
字符串 基本数据类型和引用数据类型作为方法参数 ,在传递时有什么不同之处. 答:基本数据类型按值传递,相当于复制了一份过去. 引用数据类型是指向引用 内存地址,两个地方 根据地址使用同一份数据,如被更 ...
- ORM框架 EF - code first 的封装
Code first 是Microsoft Entity Framework中的一种模式,CodeFirst不会有可视化的界面来进行拖动编辑DataBase-Entity,但会以一个类来进行对数据表关 ...
- Poj-1088-滑雪
此题为动态规划加搜索型题目 采用记忆化搜索的方式 dp[i][j]表示从坐标为 i,j 开始滑所能达到的最长距离 则dp[i][j]=max(dp[i-1][j],dp[i][j+1],dp[i+1] ...