首页 Android个性闹钟计算机毕业设计论文

Android个性闹钟计算机毕业设计论文

举报
开通vip

Android个性闹钟计算机毕业设计论文Android个性闹钟计算机毕业设计论文 找毕业设计、项目源码、编程视频,就上码农网manong365 毕业设计(论文)任务书 第1页 毕业设计(论文)题目: 基于android个性闹钟的设计与开发 毕业设计(论文)要求及原始数据(资料): 1(综述国内外Android平台相关技术的研究现状; 2(深入了解基于Android平台的闹钟程序开发环境以及相关技术; 3(熟练掌握Android平台相关技术,了解Android平台闹钟实现原理及过程; 4(深入分析实现Android闹钟关键技术与实现过程; ...

Android个性闹钟计算机毕业设计论文
Android个性闹钟计算机毕业设计 论文 政研论文下载论文大学下载论文大学下载关于长拳的论文浙大论文封面下载 找毕业设计、项目源码、编程视频,就上码农网manong365 毕业设计(论文)任务书 第1页 毕业设计(论文)题目: 基于android个性闹钟的设计与开发 毕业设计(论文)要求及原始数据(资料): 1(综述国内外Android平台相关技术的研究现状; 2(深入了解基于Android平台的闹钟程序开发环境以及相关技术; 3(熟练掌握Android平台相关技术,了解Android平台闹钟实现原理及过程; 4(深入分析实现Android闹钟关键技术与实现过程; 5(训练检索文献资料和利用文献资料的能力;(必须包含) 6(训练撰写技术文档与学位论文的能力。(必须包含) 第2页 找毕业设计、项目源码、编程视频,就上码农网manong365 毕业设计(论文)主要内容: 1(综述Android平台闹钟开发背景及意义; 2(阐述Android平台已经相关开发环境; 3(分析Android智能手机上闹钟的需求功能; 4(针对Android平台闹钟程序,编写设计流程; 5. 介绍Android平台的闹钟软件实现过程; 6(论文总结; 学生应交出的设计文件(论文): 1(内容完整、层次清晰、叙述流畅、排版规范的毕业设计论文; 2(包括毕业设计论文、源程序等内容在内的毕业设计电子文档及其它相关材料。 第3页 找毕业设计、项目源码、编程视频,就上码农网manong365 主要参考文献(资料): [1] 怡凯.基于Android的移动空间信息服务研究——以大连市公交查询信息系统为例 [J].辽宁:辽宁师范大学城市与环境学院. 2013.2.17 [2] 舒贤华.基于android平台的手机web地图服务设计[J].大连:大连海事大 学.2012.2.1 [3] 孙晓宇.Android手机界面管理系统的设计与实现. 北京 北京邮电大学.2012 [4] 韩超.Android系统原理及开发要点详解[M].北京: 电子工业出版社,2013.1 [5] 王世江.Google android SDK开发范例大全[M]. 北京:人民邮电出版社,2012. [6] 张利国.Android移动开发案例详解[M]. 北京:人民邮电出版社,2013. [7] 李宁.Android平台开发之旅[M]. 北京:机械工业出版社,2013. [8] 韩超. Android经典应用程序开发[M].北京:人力资源出版社,2011. [9] 陈会安. 中文版Java和Android开发实战详解[M].北京:人民邮电出版社,2014年1 月. [10] 李刚. 疯狂Android讲义[M].北京:电子工业出版社,2013. [11] Jeff Friesen;Learn Java for Android Development 2nd Edition;2013.10; [12] Barry Burd.Android Application Development All-in-One For D;2011.11; [13] Christopher Froehlich;The Complete Idiot's Guide to Android App Develo;2011.07; 找毕业设计、项目源码、编程视频,就上码农网manong365 专业班级 软件班 学生 要求设计(论文)工作起止日期 2014年3月17日~2014年6月27日 指导教师签字 日期 2014年3月17日 教研室主任审查签字 日期 系主任批准签字 日期 找毕业设计、项目源码、编程视频,就上码农网manong365 基于android个性闹钟的设计与开发 摘 要 随着移动平台的崛起,越来越多的传统PC软件被移植到移动平台,比如ipad,iphone,Android等智能终端设备,在这些平台中,Android占领着最大的市场份额,所以为Android用户开发满足日常使用的软件成为了现在的一大热门。 本次设计选用了时下比较热门的Android平台来作为开发技术,实现了一个多功能、全方位的闹钟软件,为用户的日常生活提供便捷、准时的提醒服务,具有非常高的实用价值和实际意义。 本论文将逐步介绍基于Android平台的移动闹钟的开发背景和意义,接着详细介绍了本系统的分析、设计与实现过程,最后对本论文做了总结。 关键字:Android;闹钟;SQLite;手机 找毕业设计、项目源码、编程视频,就上码农网manong365 Design and development of Android based on individual alarm clock ABSTRACT With the rise of mobile platforms, more and more traditional PC software has been ported to mobile platforms, such as ipad, iphone, Android and other smart terminal equipment, in these platforms, Android occupy the largest market share, so as to develop Android users meet the daily use of software has become a popular now. This design choice nowadays more popular Android platform as the development of technology, a multi-purpose, all-round alarm clock software for the user's daily life convenient, timely reminder service, has a very high practical significance. This paper will gradually introduce the background and significance of the development of Android-based mobile alarm clock, and then details the analysis of the system design and implementation process, the last of the paper summarized. Key words: Android;alarm clock;SQLite;phone 找毕业设计、项目源码、编程视频,就上码农网manong365 目 录 摘 要 ................................................................ I ABSTRACT ............................................................ II 目 录 .............................................................. III 前 言 ................................................................ 1 1 绪 论 .............................................................. 2 1.1 课题的研究背景 ............................................... 2 1.2 本课题研究现状 ............................................... 2 1.3 本文研究内容 ................................................. 3 1.4 本论文框架介绍 ............................................... 3 2 相关技术及开发平台 ................................................. 5 2.1 开发工具及环境简介 .......................................... 5 2.2 Android系统 ................................................. 6 3 系统分析 ........................................................... 9 3.1 概述 ......................................................... 9 3.1.1 系统分析的原则 .......................................... 9 3.1.2 系统分析的方法 .......................................... 9 3.2 性能需求分析 ................................................ 10 3.2.1 实用性原则 ............................................. 10 3.2.2 可扩展性与可维护性原则 ................................. 10 3.2.3 安全可靠性原则 ......................................... 10 3.2.4 用户界面美观原则 ....................................... 10 3.2.5 准确性与原则性原则 ..................................... 10 3.2.6 易用性原则 ............................................. 11 3.3 系统可行性分析 .............................................. 11 3.3.1 经济可行性 ............................................. 11 3.3.2 技术可行性 ............................................. 11 3.3.3 操作可行性 ............................................. 11 3.4 系统功能需求 ................................................ 11 3.5 系统使用流程分析 ............................................ 12 4 系统设计 .......................................................... 14 4.1 系统设计目标 ................................................ 14 4.2 系统功能模块设计 ............................................ 14 4.3 工程文件结构设计 ............................................ 15 5 系统实现 .......................................................... 19 5.1 软件主界面 .................................................. 19 5.2 添加闹钟界面实现 ............................................ 21 5.3 系统设置实现 ................................................ 23 6 系统测试 .......................................................... 26 6.1 测试的重要性 ................................................ 26 6.2 测试的目的 .................................................. 27 6.3 闹钟测试用例 ................................................ 27 总 结 ............................................................... 29 致 谢 ............................................................... 30 找毕业设计、项目源码、编程视频,就上码农网manong365 参考文献 ............................................................ 31 附 录 ............................................................... 32 外文原文 ............................................................ 39 中文翻译 ............................................................ 48 找毕业设计、项目源码、编程视频,就上码农网manong365 前 言 随着移动平台的崛起,越来越多的传统PC软件被移植到移动平台,比如ipad,iphone,Android等智能终端设备,在这些平台中,Android占领着最大的市场份额,所以为Android用户开发满足日常使用的软件成为了现在的一大热门。 在现在移动平台爆发的时代,传统的PC软件没有办法满足用户了,如果说PC的软件只能在固定的地点使用,那么现在的移动平台软件就是能够无时无刻地使用,想使用它,只需要掏出自己的手机就可以立即使用,随时随地得到最新的资讯,不再被传统PC禁锢在办公室或家中,那些必须有电源的地方了。 本设计与传统的PC软件有很大的优势,与现在的Android中其他软件相比,也具有一定的优势。现在Android软件使用风格可谓是千变万化,有很多工具软件无法满足用户的日常需要,还有很多软件由于使用风格不一,使得很多用户无法适应,把一些使用率很高的日常软件的风格统一,并且把它们的功能集中在一个软件平台中,就能使上述问题得以解决,不仅使使用风格得到了统一,也使得用户得到一站式的日常工具使用体验,并且可以使这些软件中的功能得到互补,相互共享资源,为本来硬件条件就不是很好的手机提供一个能够轻松运行的软件。本软件的优势体现: 1(随时随地使用,不受地点限制; 2(统一移动平台软件使用风格; 3(操作方便快捷、多用户独立使用; 4(数据永久性保存,随时可以翻阅查看。 1 找毕业设计、项目源码、编程视频,就上码农网manong365 1 绪 论 1.1 课题的研究背景 现在智能手机可谓是爆发式增长,传统手机在不断地消失,诺基亚就是在这样的环境中受到了极大的困扰,现在主要有三个使用率最高,关注度最高的手机平台,分别是:Android,ios和windows phone平台,这三个平台中Android的占有率最高,但是设备种类非常复杂,碎片化严重,而ios设备由于apple公司的独特管理理念,得到了一个完整的生态系统,管理得井井有条,几乎没有碎片化的现象和趋势,但是这也导致了其设备种类不多,无法满足所有用户的缺点,还有windows phone虽然现在炒作得很火热,但是其用户量相对其他的两个平台来说几乎是可以或忽略不计,所以在这里不做讨论。 Android平台是一个面向大众的系统,分布在低端,中端和高端市场中,在各个阶段的是市场中都有很受欢迎的机型,并且Android是开源的,开发者随时都可以查看系统源代码,并且使用时下最流行的java作为其主要的开发语言。由于这些特点,使得Android成为现在市场占有量最大的软件平台,在这样的平台上面开发一款独特的日常生活软件尤为必要的。 1.2 本课题研究现状 Android一词的本义指“机器人”。同时也是Google于2007年11月5日宣布的基于Linux平台的开源手机操作系统的名称 该平台由操作系统、中间件、用户界面和应用软件组成 号称是首个为移动终端打造的真正开放和完整的移动软件。 Android是基于Linux内核的软件平台和操作系统 早期由Google开发 在华注册商标名为“安致”,后由开放手机联盟、Open Handset Alliance开发。它采用了软件堆层,software stack,又名以软件叠层的架构主要分为三部分。低层以Linux内核工作为基础,只提供基本功能,其他的应用软件则由各公司自行开发,以Java作为编写程序的一部分。另外 ,为了推广此技术,Google和其它几十个手机公司建立了开放手机联盟。Android在未公开之前常被传闻为Google电话或gPhone。大多传闻认为Google开发的是自己的手机电话产品,而不是一套软件平台。到了2010年1月,Google开始发表自家品牌手机电话的Nexus One。目前最新SDK版本为Android 4.4.2。 目前Android平台的应用软件已经很多,涉及到生活、娱乐、系统管理、办公等等一系列领域,同时闹钟技术在Android平台的应用已经非常广泛,本课题闹钟也是安卓平台常见的软件之一。 2 找毕业设计、项目源码、编程视频,就上码农网manong365 1.3 本文研究内容 本文主要介绍和阐述一个手机平台的软件如何实现一个个性化闹钟的过程。 本应用软件使用简单,易学易会,非常容易上手,主要是在UI设计上采用了移动平台上最主流的设计理念:简单和引导,虽然界面相对传统PC界面显得简单,但是其功能是毫不逊色的,在保留其功能全面性的基础上,设计了最简单的界面来进行展示和操作,使得用户能够不需要事先的任何学习,就可以熟练地进行操作。 本软件包括的功能有闹钟设置、闹钟创建、闹钟保存等模块。 软件的设计步骤: 1) 了解相关资料,了解本软件的研究意义,确定实现技术与方式设计总 目标及其整体框架。 2) 了解用户的使用习惯和使用心理,进行用户需求分析和规范。 3) 草拟功能模块,画出模块图。 4) 搜集软件制作素材。 5) 界面设计及完善,编写代码。 6) 编写代码实现各个功能模块。 7) 根据Android特有的使用风格进行布局与优化。 8) 完成系统测试并改进。 1.4 本论文框架介绍 本文详细介绍了基于Android手机平台的闹钟的设计实现的全过程。从开始到程序设计的实现,将在一下的几章中予以介绍: 第1章 绪论,这一章主要是对本次毕业设计所开发的系统进行问题的定义,通过问题的定义明白需要做些什么,并且对开发内容简单的介绍了一下;同时本章还对课题的研究背景与研究意义进行分析,对开发本系统的可行性分析还有对论文各章内容的简要介绍。 3 找毕业设计、项目源码、编程视频,就上码农网manong365 第2章 相关技术及平台介绍,对涉及到的理论知识和用到的开发工具做相关阐述。 第3章 系统分析,主要介绍了本系统需要实现的功能模块和本系统的数据库设计、页面的详细设计等。 第4章 系统设计,主要介绍了本系统的整个设计过程、设计思路以及设计中应该注意的问题。 第5章 系统编码实现与测试,主要介绍了本设计的实现环境和实现,同时也介绍了测试在软件开发环节中的重要性和给出本系统的测试过程与结论。 最后:总结、致谢、参考文献。 4 找毕业设计、项目源码、编程视频,就上码农网manong365 2 相关技术及开发平台 2.1 开发工具及环境简介 a. Eclipse Classic 3.7.2 Eclipse 是一个开放源代码的、基于 Java 的可扩展开发平台。就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境。幸运的是,Eclipse 附带了一个标准的插件集,包括 Java 开发工具(Java Development Kit,JDK)。 Eclipse是著名的跨平台的自由集成开发环境(IDE)。最初主要用来Java语言开发,但是目前亦有人通过插件使其作为其他计算机语言比如C++和Python的开发工具。Eclipse的本身只是一个框架平台,但是众多插件的支持使得Eclipse拥有其他功能相对固定的IDE软件很难具有的灵活性。许多软件开发商以Eclipse为框架开发自己的IDE。Eclipse 最初由OTI和IBM两家公司的IDE产品开发组创建,起始于1999年4月。IBM提供了最初的Eclipse代码基础,包括Platform、JDT 和PDE。目前由IBM牵头,围绕着Eclipse项目已经发展成为了一个庞大的Eclipse联盟,有150多家软件公司参与到Eclipse项目中,其中包括Borland、Rational Software、Red Hat及Sybase等。Eclipse是一个开发源码项目,它其实是 Visual Age for Java的替代品,其界面跟先前的Visual Age for Java差不多,但由于其开放源码,任何人都可以免费得到,并可以在此基础上开发各自的插件,因此越来越受人们关注。近期还有包括Oracle在内的许多大公司也纷纷加入了该项目,并宣称Eclipse将来能成为可进行任何语言开发的IDE集大成者,使用者只需下载各种语言的插件即可。 b. SQLite3 SQLite3是一款轻型的数据库,是遵守ACID的关联式数据库管理系统。它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中使用了它,占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够支持Windows/Linux/Unix等等主流的操作系统,同时能够跟很多程序语言相结合,比如 Tcl、C#、PHP、Java等,还有ODBC接口,同样比起Mysql、PostgreSQL这两款开源世界著名的数据库管理系统来讲,它的处理速度比他们都快。SQLite第一 5 找毕业设计、项目源码、编程视频,就上码农网manong365 个Alpha版本诞生于2000年5月. 至今已经有10个年头,SQLite也迎来了一个版本 SQLite 3已经发布。 c. ADT 目前Android开发所用的开发工具是Eclipse,在Eclipse编译IDE环境中,安装ADT,为Android开发提供开发工具的升级或者变更,简单理解为在Eclipse下开发工具的升级下载工具。 d. Android SDK SDK:(software development kit)软件开发工具包。被软件开发工程师用于为特定的软件包、软件框架、硬件平台、操作系统等建立应用软件的开发工具的集合。因此,Android SDK 指的既是Android专属的软件开发工具包。 2.2 Android系统 Android一词的本义指“机器人” 同时也是Google于2007年11月5日宣布的基于Linux平台的开源手机操作系统的名称 该平台由操作系统、中间件、用户界面和应用软件组成,号称是首个为移动终端打造的真正开放和完整的移动软件。 [1]Android系统有如下的几大特性 ?应用程序框架 支持组件的重用与替换 ?Dalvik虚拟机 专门为移动设备做了优化 ?内部集成浏览器 该浏览器基于开源的WebKit引擎 ?优化的图形库 包括2D和3D图形库 3D图形库基于OpenGL ES ?SQLite 用作结构化的数据存储 ? 多媒体支持 包括常见的音频、视频和静态印象文件格式 如MPEG4, MP3, AAC, AMR, JPG, PNG ?GSM电话 依赖于硬件 ?蓝牙Bluetooth, EDGE, 3G, and WiFi 依赖于硬件 6 找毕业设计、项目源码、编程视频,就上码农网manong365 ?照相机 GPS 指南针 和加速度计 依赖于硬件 ?丰富的开发环境 包括设备模拟器、调试工具、内存及性能分析图表; 在Android系统中 为我们提供了四大基本组件 每个组件是一个视图 但是有些是可见的 有些是不可见的视图 像Activity ContentProvider是可见的视图 Service和BroadcastReceiver是不可见的 它们只在系统的后台运行。下面分别介绍四大组件[3] 1 Activity 简介 在Android系统中Activity提供可视化的用户界面,一个Android应用通常由多个 Activity组成。多个Activity组成了Activity栈Stack,当前活动的Activity处于栈顶。Activity有自己的生命周期,由Android系统来控制。 2 Service 简介 顾名思义Service就是运行在后台的一种服务程序 一般很少和用户交互 因此没有可视化界面定义一个Service类比较简单,只要继承Service类,实现其生命周期中的方法就可以了。一个定义好的Service必须在AndroidManifest.xml配置文件注册 通过元素声明才能使用.Service有自己的生命周期 我们可以调用startService()启动 一个Service或者bindService()方法来绑定一个存在的Service 3 Broadcast Receiver 简介 Broadcast Receiver 顾名思义广播接收器,它和事件处理机制类似,只不过事件处理机制是程序组件级别的。例如某个按钮的单击事件而广播事件处理机制是系统级别的。到目前为止我们可以使用Intent来启动一个程序组件,我们还可以通过使用sendBroadcast()方法来发起一个系统级别的事件广播来传递消息。我们可以在你的应用程序中实现Broadcast Receiver来监听和响应这些广播的Intent ; 4 ContentProvider简介 Content Provider 用来保存和检索数据 并且使应用程序之间相互访问数据成为可能。它是跨应用程序共享数据的唯一方法。 Android 为常用的数据类型 如 7 找毕业设计、项目源码、编程视频,就上码农网manong365 音视频、图片和联系方式等提供了大量的Content Provider。它们被定义在android.provider包下面。通过这样定义好ContentProvider 我们可以方便的进行数据操作。当然我们必须拥有适当的权限。我们也可以自己来定ContentProvider共享我们的数据 方便用户的访问。 8 找毕业设计、项目源码、编程视频,就上码农网manong365 3 系统分析 3.1 概述 系统分析是在总体规划的指导下,对某个或若干个子系统进行深入仔细地调查研究,确定新系统逻辑功能的过程。这一阶段的主要任务是由系统分析员了解每个业务流程,工作流程,广大用户的需求,运用系统开发理论、开发方法和开发技术设计出一个计算机化的信息系统。 3.1.1 系统分析的原则 在闹钟系统分析中存在很多困难,为了克服困难,做好分析工作,在进行系统分析时应遵循系统分析的原则,这样才能保证分析工作能够顺利进行,系统分析的原则有: 1.逻辑设计与物理设计分开的原则 2.面向用户的原则 3.结构化分析的原则 通过实际调查并与相关用户交流后,分析Android平台闹钟的具体的要求,确定本网站系统的逻辑功能,以满足用户的各项要求,完成相应的各项功能,提高网站的实用水平。在近期目标完成后,该系统应该有很强的扩充性,便于在此基础上进行扩充式开发,为以后的发展及扩充打好基础。 3.1.2 系统分析的方法 该闹钟软件采用以抽象和分解为手段,并且采用结构化分析方法进行系统分析,根据实际调查研究,对系统进行自顶向下的逐层分解,逐步细分,逐步求精,建立新系统的逻辑模型,这个逻辑模型将尽可能避免使用计算机术语,让其尽可能的简单化、通俗化,便于设计者和浏览者的沟通与交流经验。 结构化分析方法的基本思想是该系统采用结构化分析方法,以抽象和分解为手段,对系统进行自顶向下的逐层分解,逐步细分,逐步求精,从而达到易于理解的目的。 9 找毕业设计、项目源码、编程视频,就上码农网manong365 3.2 性能需求分析 为了保证软件能够长期、安全、稳定、可靠、高效地在Android设备上运行,本系统应该满足以下性能需求。 3.2.1 实用性原则 充分利用手机的硬件资源优势,为本软件提供信息支持,充分考虑用户获取信息的心理需求,在简洁实用的基础上对软件界面层级进行布局。 3.2.2 可扩展性与可维护性原则 为适应将来的发展,软件应该具有良好的可扩展性和可维护性。系统设计尽可能模块化、组件化,由于Android设备分辨率的各不相同,使软件可灵活配置,适应不同的的Android终端设备。系统的可扩展性应包括能接纳已有的系统和在今后系统软硬件扩展时,能有效地保护已有的资源建设。当用户的需求有所改变时,可以对其快速的配置改变,以应对用户的需求,有一个较好的应用平台——Android设备,能容易地安装和卸载。系统易于扩充升级,既能满足当前业务的需求,将来的需求改变升级也被考虑在内。 3.2.3 安全可靠性原则 本软件是基于手机设备使用的,其安全性与其他的应用软件是一样的,本软件不会残留用户任何的隐私信息。 3.2.4 用户界面美观原则 界面经过对用户心理的调研和统计后。并参考时下流行的软件风格进行设计,在此基础上,加入了对用户具有诱导性的按键设计,使得用户在初次使用的时候就会使用,而不需要在使用的时候进行特别的学习和指导。 3.2.5 准确性与原则性原则 软件的准确性是成败的关键,本软件最核心的技术便是通过SOAP技术与互联网上提供的接口进行交互,本软件采用特殊处理来保证数据获取的准确性和及时性,从软件的布局还是数据呈现方面,都是经过对用户心理的研究和与其他数据 10 找毕业设计、项目源码、编程视频,就上码农网manong365 对比的来的。 3.2.6 易用性原则 软件是Android平台上的软件,自然保留了Android软件的应用性原则,平易近人,不需要额外学习,看到任何一个界面都不会不知所措,会有不同含义的图标进行提示下一步操作,保证用户使用时不会迷路。 3.3 系统可行性分析 该阶段通过对系统总目标的初步调研与分析,提出可行性方案并进行论证。在此,主要从技术可行性、经济可行性和操作可行性三方面进行分析。 3.3.1 经济可行性 本软件采用手机软件的形式呈现,与传统的pc软件相比具有,携带方便,随之随地获取信息的特点,不受地理和时间的限制的特点,可以充分充分利用人们的闲暇时间,从这个角度看,该软件可行。 3.3.2 技术可行性 开发工具:Eclipse Classic 3.7.2 数据库环境:sqlite3 系统环境:Microsoft Windows 7或以上版本 软件实现是依靠基于Android系统的开发技术,使用的是java为主的开发语言进行开发,再加上SQlite数据存取技术。 3.3.3 操作可行性 软件采用最主流的Android软件应用开发风格,并使用Android的原生组件进行开发,界面友好,简洁易懂,组建布局具有诱导性,用户使用极其方便快捷。 3.4 系统功能需求 该基于Android的闹钟软件实现了包括Android平台上的闹钟设置、闹钟个性化设置、闹钟添加修改、系统设置等功能,具体来说,本系统包含以下功能: 11 找毕业设计、项目源码、编程视频,就上码农网manong365 (1)闹钟获取 获取当前已经设置的闹钟信息,包括闹钟的提醒时间、提醒方式等等信息。 (2)添加闹钟 添加闹钟提醒,可以自动提醒时间、提醒周期,还可以自定义个性化闹钟标签,可以自定义提醒铃声等等信息。 (3)添加删除 可以删除一个已经设置好的闹钟。 (4)系统设置 设置闹钟延迟提醒、提醒铃声大小等等信息 3.5 系统使用流程分析 在系统分析和开发系统过程中,采用了一些相对比较成熟、安全性较高、运行比较稳定的技术。这些技术贯穿了整个系统的设计与开发过程,是设计和实现各个模块的基础技术,只有运用先进的设计模式和开发技术,才能保证开发工作顺利地进行,才能保证系统设计的合理性和灵活性,才能保证各个功能模块的稳定性。 闹钟系统的设置有闹钟创建到闹钟提醒,图3-1是系统的流程图: 12 找毕业设计、项目源码、编程视频,就上码农网manong365 图 3-1 软件流程图 13 找毕业设计、项目源码、编程视频,就上码农网manong365 4 系统设计 4.1 系统设计目标 在系统分析的基础上,设计出能满足预定目标的系统的过程。系统设计内容主要包括:确定设计方针和方法,将系统分解为若干子系统,确定各子系统的目标、功能及其相互关系,决定对子系统的管理体制和控制方式,对各子系统进行技术设计和评价,对全系统进行技术设计和评价等。 本系统是设计目标是建立一个基于Android的闹钟,基本实现了一个闹钟应有的功能,具有操作方便快捷等特点。 用户界面友好、操作简单,每一步骤的操作都经过精心的设计,将复杂的统计运算过程隐藏于简单的操作之下,系统的设计能降低使用前的培训、实施和使用中的维护时间。 通过合理而先进的网络设计及软、硬件的优化选型,足可保证系统的可靠性与容错性。系统以用户需求为目标,以方便用户为原则,处处为使用者着想。 4.2 系统功能模块设计 本闹钟软件功能包括闹钟查询、闹钟创建和系统设置等模块,系统的模块架构设计如图4-1所示: 14 找毕业设计、项目源码、编程视频,就上码农网manong365 图 4-1 系统功能模块图 4.3 工程文件结构设计 在程序开发阶段,首先确定“即基于AlarmClockApp的闹钟软件设计”的工程名称为AlarmClockApp,根据程序模块设计的内容,建立AlarmClockApp项目, AlarmClockApp项目的文件结构如图4-2所示: 15 找毕业设计、项目源码、编程视频,就上码农网manong365 图 4-2工程结构图 为了使代码文件结构更加清晰, LifeButler工程设置了多个命名空间,分别保存了用户界面、数据适配器、常用类库和实体多个包,源代码的名称以及说明如表4.1所示: 16 找毕业设计、项目源码、编程视频,就上码农网manong365 4.1 系统代码结构 表 包名称 文件名 说明 com.mm.alarmclock.activity MainActivity.java 主界面视图 com.mm.alarmclock.activity EditAlarmActivity.java 闹钟编辑界面视图 com.mm.alarmclock.activity SettingsActivity1.java 设置界面视图 com.mm.alarmclock.activity RemindActivity.java 提醒界面视图 com.mm.alarmclock.activity AlarmService.java 闹钟服务 Android的资源文件保存在/res的子目录中。其中、/res/anim目录中保存的是产生动画效果的XML文件,/res/drawable/目录中保存的是图像文件,/res/values目录中保存的是用来自定义字符串和颜色的文件,/res/xml目录中保存的是XML格式的数据文件。所有在程序开发阶段可以被调用的资源都保存在这些目录中,具体每个资源文件的用途可以参考表4.2: 17 找毕业设计、项目源码、编程视频,就上码农网manong365 4.2 资源文件名称及用途 表 资源目录 文件名 说明 btn_comm_selector.xml 按钮资源文件 checkbox_selector1.xml listview_item_selector.xml Drawable spinner_bg.xml activity_edit_alarm.xml 闹钟设置布局文件 activity_main_alarm.xml 主界面布局文件 activity_remind.xml 提醒结果布局文件 Layout activity_set.xml 设置界面布局文件 layout_top_title.xml 生成界面布局文件 styles.xml 样式资源文件 values colors.xml 颜色资源文件 strings.xml 字符串资源文件 18 找毕业设计、项目源码、编程视频,就上码农网manong365 5 系统实现 本章介绍本系统的各个模块的设计和实现。首先在Eclipse中配置好ADT和Android SDK等开发环境,然后新建一个Android项目,项目名为AlarmClockApp,然后在Android项目中的AndroidManifest.xml文件中配置本软件需要使用的权限。 5.1 软件主界面 闹钟主界面显示了当前已经设置的所有闹钟信息,包括闹钟提醒时间、提醒周期和是否开启等信息。 列表的左边为一个图标,高亮的图标表示该闹钟是开启的,灰色图标则表示该闹钟当前无效没启动; 同时该界面包括了添加闹钟按钮盒系统设置按钮,点击添加闹钟可以进入到闹钟添加界面,点击系统设置图标则可以进入系统设置模块。 具体的实现效果如图5-1所示: 19 找毕业设计、项目源码、编程视频,就上码农网manong365 图5-1 主界面 实现核心代码: // 加载更新界面布局 private void updateLayout() { setContentView(R.layout.activity_main_alarm); ((TextView) findViewById(R.id.tvTopTitleCenter)).setText("闹钟"); mAlarmsList = (ListView) findViewById(R.id.alarms_list); AlarmTimeAdapter adapter = new AlarmTimeAdapter(this, mCursor); mAlarmsList.setAdapter(adapter); mAlarmsList.setVerticalScrollBarEnabled(true); mAlarmsList.setOnItemClickListener(this); mAlarmsList.setOnCreateContextMenuListener(this); ivTopTitleLeft = (ImageView) findViewById(R.id.ivTopTitleLeft); 20 找毕业设计、项目源码、编程视频,就上码农网manong365 ivTopTitleLeft.setVisibility(View.VISIBLE); ivTopTitleLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, EditAlarmActivity.class)); } }); ivTopTitleRight = (ImageView) findViewById(R.id.ivTopTitleRight); ivTopTitleRight.setVisibility(View.VISIBLE); ivTopTitleRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, SettingsActivity1.class)); } }); } 5.2 添加闹钟界面实现 用户进入到闹钟设置界面后可以看到各种选择设置功能。 在该界面里用户可以设置闹钟的提醒时间,时间的设置时通过Android平台的TimePickerDialog组件来实现; 同时用户还可以自定义自己的闹钟标签,例如“起床”或“喝水”等标签文本; 最后可以设置闹钟的提醒铃声和是否震动提示,提醒铃声可以自定义选择手机里的音乐文件; 实现核心代码: private void findview() { ((TextView) findViewById(R.id.tvTopTitleCenter)).setText("闹钟设置"); findViewById(R.id.rlCycle).setOnClickListener(this); 21 找毕业设计、项目源码、编程视频,就上码农网manong365 findViewById(R.id.rlTime).setOnClickListener(this); findViewById(R.id.rlRing).setOnClickListener(this); tvRing = (TextView) findViewById(R.id.tvRing); tvTime = (TextView) findViewById(R.id.tvTime); tvTime.setText(mHour + ":" + mMinutes); tvCycle = (TextView) findViewById(R.id.tvCycle); tvCycle.setText("响一次"); checkbox1 = (CheckBox) findViewById(R.id.checkbox1); checkbox2 = (CheckBox) findViewById(R.id.checkbox2); etLabel = (EditText) findViewById(R.id.etLabel); btnOK = (Button) findViewById(R.id.btnOK); btnCancel = (Button) findViewById(R.id.btnCancel); btnOK.setOnClickListener(this); btnCancel.setOnClickListener(this); } 具体的实现效果如图5-2所示: 22 找毕业设计、项目源码、编程视频,就上码农网manong365 图5-2 闹钟设置界面 5.3 系统设置实现 闹钟软件系统设置包括“静音是否响铃”、“音量设置”和“延迟提醒时间设置”这三个选项,用户可以根据自己的习惯进行个性化设置。 23 找毕业设计、项目源码、编程视频,就上码农网manong365 实现核心代码: private void findview() { ((TextView) findViewById(R.id.tvTopTitleCenter)).setText("系统设置"); checkbox1 = (CheckBox) findViewById(R.id.checkbox1); tvDelay = (TextView) findViewById(R.id.tvDelay); tvDelay.setText(duration); checkbox1.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int ringerModeStreamTypes = Settings.System.getInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); if (isChecked) { ringerModeStreamTypes &= ~ALARM_STREAM_TYPE_BIT; { } else ringerModeStreamTypes |= ALARM_STREAM_TYPE_BIT; } Settings.System.putInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, ringerModeStreamTypes); BaseUtil.LogII(Settings.System.getInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0)); } }); final int silentModeStreams = Settings.System.getInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); checkbox1.setChecked((silentModeStreams & ALARM_STREAM_TYPE_BIT) == 0); 24 找毕业设计、项目源码、编程视频,就上码农网manong365 findViewById(R.id.rlDelay).setOnClickListener(this); findViewById(R.id.rlVolume).setOnClickListener(this); } 具体的实现效果如图5-3所示: 图5-3 系统设置界面 25 找毕业设计、项目源码、编程视频,就上码农网manong365 6 系统测试 6.1 测试的重要性 软件的测试在软件生命周期中占据重要的地位,在传统的瀑布模型中,软件测试学仅处于运行维护阶段之前,是软件产品交付用户使用之前保证软件质量的重要手段。近来,软件工程界趋向于一种新的观点,即认为软件生命周期每一阶段中都应包含测试,从而检验本阶段的成果是否接近预期的目标,尽可能早的发现错误并加以修正,如果不在早期阶段进行测试,错误的延时扩散常常会导致最后成品测试的巨大困难。 事实上,对于软件来讲,不论采用什么技术和什么方法,软件中仍然会有错。采用新的语言、先进的开发方式、完善的开发过程,可以减少错误的引入,但是不可能完全杜绝软件中的错误,这些引入的错误需要测试来找出,软件中的错误密度也需要测试来进行估计。测试是所有工程学科的基本组成单元,是软件开发的重要部分。自有程序设计的那天起测试就一直伴随着。统计表明,在典型的软件开发项目中,软件测试工作量往往占软件开发总工作量的40,以上。而在软件开发的总成本中,用在测试上的开销要占30,到50,。如果把维护阶段也考虑在内,讨论整个软件生存期时,测试的成本比例也许会有所降低,但实际上维护工作相当于二次开发,乃至多次开发,其中必定还包含有许多测试工作。 在实践中,软件测试的困难常常使人望而却步或敷衍了事,这是由于对测试仍然存在一些不正确的看法和错误的态度,这包括: (1)认为测试工作不如设计和编码那样容易取得进展难以给测试人员某种成就感; (2)以发现软件错误为目标的测试是非建设性的,甚至是破坏性的,测试中发现错位是对责任者工作的一种否定; (3)测试工作枯燥无味,不能引起人们的兴趣; (4)测试工作是艰苦而细致的工作; (5)对自己编写的程序盲目自信,在发现错误后,顾虑别人对自己的开发能力 26 找毕业设计、项目源码、编程视频,就上码农网manong365 的看法。 这些观点对软件测试工作是极为不利的,必须澄清认识、端正态度,才可能提高软件产品的质量。 6.2 测试的目的 如果测试的目的是为了尽可能多地找出错误,那么测试就应该直接针对软件比较复杂的部分或是以前出错比较多的位置。如果测试目的是为了给最终用户提供具有一定可信度的质量评价,那么测试就应该直接针对在实际应用中会经常用到的商业假设。 在谈到软件测试时,许多人都引用Grenford J. Myers在《The Art of Software Testing》一书中的观点: (1)软件测试是为了发现错误而执行程序的过程; (2)测试是为了证明程序有错,而不是证明程序无错误; (3)一个好的测试用例是在于它能发现至今未发现的错误; (4)一个成功的测试是发现了至今未发现的错误的测试。 这种观点可以提醒人们测试要以查找错误为中心,而不是为了演示软件的正确功能。但是仅凭字面意思理解这一观点可能会产生误导,认为发现错误是软件测试的唯一目,查找不出错误的测试就是没有价值的,事实并非如此。 首先,测试并不仅仅是为了要找出错误。通过分析错误产生的原因和错误的分布特征,可以帮助项目管理者发现当前所采用的软件过程的缺陷,以便改进。同时,这种分析也能帮助我们设计出有针对性地 检测 工程第三方检测合同工程防雷检测合同植筋拉拔检测方案传感器技术课后答案检测机构通用要求培训 方法,改善测试的有效性。其次,没有发现错误的测试也是有价值的,完整的测试是评定测试质量的一种方法。 6.3 闹钟测试用例 通过测试来验证系统的闹钟提醒功能是否正常。 首先我们设置一个闹钟并启动,待时间到了观察系统是否有提醒: 27 找毕业设计、项目源码、编程视频,就上码农网manong365 图6-1测试用例图 可以看到系统已经提醒了,由此可见程序是没问题的; 经过上述测试,本系统各项操作中均可按照预期的设计运行,实现了系统的开发目标与要求。重要的是,还要从最终用户的角度进行安全性和可用性测试。完成了系统的基本功能。实施开发 计划 项目进度计划表范例计划下载计划下载计划下载课程教学计划下载 管理,质量计划管理,进行产品的设计和实现;进行多层次的测试和验证,交付安装时提供义务期限;提供维护支持、配置管理、文档控制、质量 记录 混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载 、培训人员和其它支持活动等; 总之,加强质量管理,针对所有可能影响软件质量的各个因素都要采取有力措施,作出加强质量管理和控制的决定。与质量有关的人员都要规定其职责和权限,使责任落实到人,保证产品质量真正得到控制。 28 找毕业设计、项目源码、编程视频,就上码农网manong365 总 结 本系统较完整的实现了基于Android的闹钟系统的设计与实现基本功能。完成了最初系统设计中闹钟设置、闹钟创建、系统设置等等模块的实现工作。 从本系统的开发过程中,我受益匪浅。首先,我认识到了代码规范的重要性,特别是在一些大型项目中,用到的函数可能有数百个,如果编写的代码不规范会给后期的检查带来极大的麻烦。而且完整的代码测试也非常重要,有些错误可能在很久以后才能发现。其次,我意识到了软件设计的重要性,原来接触的项目往往是快速开发类型的,几乎不需要在软件的逻辑设计上花费太多时间,往往可以边开发边进行下一步的设计。但是这一次我意识到做软件设计很重要,当初一个设计没注意,可能造成后来的编码大面积的返工。最后就是调试方法的重要性,系统的调试过程要比开发过程繁琐的多。 29 找毕业设计、项目源码、编程视频,就上码农网manong365 致 谢 经过两个多月的努力,自己终于完成了毕业设计和毕业论文的写作工作,在这里我要感谢我的设计指导老师,是她在论文的选题及技术方向上给我提出许多宝贵的设计意见,在最后的测试修改阶段又在百忙之中抽出时间为我提供了必要的帮助,这样使得我得以顺利的完成毕业设计开发工作,老师渊博的知识、敏锐的思路和实事求是的工作作风给我留下了深刻的印象,这将使得我终身受益,谨此向老师表示衷心的感谢。 感谢在校的老师们,在我大学时间里对我的谆谆教诲和无私帮助,在实际的开发工作中,我深深 体会 针灸治疗溃疡性结肠炎昆山之路icu常用仪器的管理名人广告失败案例两会精神体会 到了基础理论知识的重要性,在大学阶段只有好好学习,掌握好扎实的理论基础,这样才能在将来的工作中更快的学习,从而得心应手,有所成就,真正成为一个对社会和他人有用的人。 最后还要感谢我的同学们,在这次毕业设计及论文写作中给我的支持和帮助。 30 找毕业设计、项目源码、编程视频,就上码农网manong365 参考文献 [1] 怡凯.基于Android的移动空间信息服务研究——以大连市公交查询信息系统为例[J].辽宁: 辽宁师范大学城市与环境学院. 2013.2.17 [2] 舒贤华.基于android平台的手机web地图服务设计[J].大连:大连海事大学.2012.2.1 [3] 孙晓宇.Android手机界面管理系统的设计与实现. 北京 北京邮电大学.2012 [4]韩超.Android系统原理及开发要点详解[M].北京: 电子工业出版社,2013.1 [5]王世江.Google android SDK开发范例大全[M]. 北京:人民邮电出版社,2012. [6]张利国.Android移动开发案例详解[M]. 北京:人民邮电出版社,2013. [7]李宁.Android平台开发之旅[M]. 北京:机械工业出版社,2013. [8] 韩超. Android经典应用程序开发[M].北京:人力资源出版社,2011. [9] 陈会安. 中文版Java和Android开发实战详解[M].北京:人民邮电出版社,2014年1月. [10] 李刚. 疯狂Android讲义[M].北京:电子工业出版社,2013. [11] Jeff Friesen;Learn Java for Android Development 2nd Edition;2013.10; [12] Barry Burd.Android Application Development All-in-One For D;2011.11; [13] Christopher Froehlich;The Complete Idiot's Guide to Android App Develo;2011.07; [14] Andrew Hoog;Android Forensics /Andrew Hoog;Syngress;2011.06; [15] Andrew Clare;The Rough Guide to Android Phones and Tablets /A;Rough Guides;2012.04; 31 找毕业设计、项目源码、编程视频,就上码农网manong365 附 录 package com.mm.alarmclock.activity; import java.util.Calendar; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.KeyEvent; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.miebo.utils.BaseActivity; import com.miebo.utils.SPUtil; import com.mm.alarmclock.Alarm; import com.mm.alarmclock.Alarms; import com.mm.alarmclock.R; import com.mm.alarmclock.receiver.AlarmReceiver; @SuppressWarnings("deprecation") public class RemindActivity extends BaseActivity { 32 找毕业设计、项目源码、编程视频,就上码农网manong365 private static final String DEFAULT_SNOOZE = "10";// 贪睡时间(分钟) private static final String DEFAULT_VOLUME_BEHAVIOR = "2"; protected static final String SCREEN_OFF = "screen_off"; protected Alarm mAlarm; private int mVolumeBehavior; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_remind); mAlarm = getIntent().getParcelableExtra(Alarms.ALARM_INTENT_EXTRA); mAlarm = Alarms.getAlarm(getContentResolver(), mAlarm.id); final String vol = PreferenceManager.getDefaultSharedPreferences(this).getString( SettingsActivity1.KEY_VOLUME_BEHAVIOR, DEFAULT_VOLUME_BEHAVIOR); mVolumeBehavior = Integer.parseInt(vol); mVolumeBehavior = SPUtil.get(this, SettingsActivity1.KEY_VOLUME_BEHAVIOR, 70); findview(); IntentFilter filter = new IntentFilter(Alarms.ALARM_KILLED); filter.addAction(Alarms.ALARM_SNOOZE_ACTION); filter.addAction(Alarms.ALARM_DISMISS_ACTION); registerReceiver(mReceiver, filter); } private void setTitle() { String label = mAlarm.getLabelOrDefault(this); TextView title = (TextView) findViewById(R.id.alertTitle); title.setText(label); } 33 找毕业设计、项目源码、编程视频,就上码农网manong365 private void findview() { Button snooze = (Button) findViewById(R.id.snooze); snooze.requestFocus(); snooze.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { snooze(); } }); findViewById(R.id.dismiss).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { dismiss(false); } }); setTitle(); } private void snooze() { if (!findViewById(R.id.snooze).isEnabled()) { dismiss(false); return; } String snooze = SPUtil.get(this, SettingsActivity1.KEY_ALARM_SNOOZE, DEFAULT_SNOOZE); int snoozeMinutes = Integer.parseInt(snooze); 34 找毕业设计、项目源码、编程视频,就上码农网manong365 final long snoozeTime = System.currentTimeMillis() + (1000 * 60 * snoozeMinutes); Alarms.saveSnoozeAlert(RemindActivity.this, mAlarm.id, snoozeTime); final Calendar c = Calendar.getInstance(); c.setTimeInMillis(snoozeTime); String label = mAlarm.getLabelOrDefault(this); label = getString(R.string.alarm_notify_snooze_label, label); Intent cancelSnooze = new Intent(this, AlarmReceiver.class); cancelSnooze.setAction(Alarms.CANCEL_SNOOZE); cancelSnooze.putExtra(Alarms.ALARM_ID, mAlarm.id); PendingIntent broadcast = PendingIntent.getBroadcast(this, mAlarm.id, cancelSnooze, 0); NotificationManager nm = getNotificationManager(); Notification n = new Notification(R.drawable.nz01, label, 0); n.setLatestEventInfo(this, label, getString(R.string.alarm_notify_snooze_text, Alarms.formatTime(this, c)), broadcast); n.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONGOING_EVENT; nm.notify(mAlarm.id, n); String displayTime = getString(R.string.alarm_alert_snooze_set, snoozeMinutes); Toast.makeText(RemindActivity.this, displayTime, Toast.LENGTH_LONG).show(); stopService(new Intent(Alarms.ALARM_ALERT_ACTION)); finish(); } private NotificationManager getNotificationManager() { return (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } 35 找毕业设计、项目源码、编程视频,就上码农网manong365 private void dismiss(boolean killed) { if (!killed) { NotificationManager nm = getNotificationManager(); nm.cancel(mAlarm.id); stopService(new Intent(Alarms.ALARM_ALERT_ACTION)); } finish(); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); mAlarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA); setTitle(); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(Alarms.ALARM_SNOOZE_ACTION)) { snooze(); } else if (action.equals(Alarms.ALARM_DISMISS_ACTION)) { dismiss(false); } else { Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA); if (alarm != null && mAlarm.id == alarm.id) { 36 找毕业设计、项目源码、编程视频,就上码农网manong365 dismiss(true); } } } }; @Override protected void onResume() { super.onResume(); if (Alarms.getAlarm(getContentResolver(), mAlarm.id) == null) { Button snooze = (Button) findViewById(R.id.snooze); snooze.setEnabled(false); } } @Override public void onDestroy() { super.onDestroy(); unregisterReceiver(mReceiver); } @Override public boolean dispatchKeyEvent(KeyEvent event) { boolean up = event.getAction() == KeyEvent.ACTION_UP; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_FOCUS: 37 找毕业设计、项目源码、编程视频,就上码农网manong365 if (up) { switch (mVolumeBehavior) { case 1: snooze(); break; case 2: dismiss(false); break; default: break; } } return true; default: break; } return super.dispatchKeyEvent(event); } @Override public void onBackPressed() { return; } } 38 找毕业设计、项目源码、编程视频,就上码农网manong365 外文原文 Android applications are written in the Java programming language. The Android SDK along with any data and resource files—into an Android package, tools compile the code— an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application. Once installed on a device, each Android application lives in its own security sandbox: , The Android operating system is a multi-user Linux system in which each application is a different user. , By default, the system assigns each application a unique Linux user ID (the ID is used only by the system and is unknown to the application). The system sets permissions for all the files in an application so that only the user ID assigned to that application can access them. , Each process has its own virtual machine (VM), so an application's code runs in isolation from other applications. , By default, every application runs in its own Linux process. Android starts the process when any of the application's components need to be executed, then shuts down the process when it's no longer needed or when the system must recover memory for other applications. In this way, the Android system implements the principle of least privilege. That is, each application, by default, has access only to the components that it requires to do its work and no more. This creates a very secure environment in which an application cannot access parts of the system for which it is not given permission. However, there are ways for an application to share data with other applications and for an application to access system services: , It's possible to arrange for two applications to share the same Linux user ID, in which case they are able to access each other's files. To conserve system resources, applications with the same user ID can also arrange to run in the same Linux process and share the same VM (the applications must also be signed with the same certificate). , An application can request permission to access device data such as the user's contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All application permissions must be granted by the user at install time. That covers the basics regarding how an Android application exists within the system. The rest of this document introduces you to: , The core framework components that define your application. 39 找毕业设计、项目源码、编程视频,就上码农网manong365 , The manifest file in which you declare components and required device features for your application. , Resources that are separate from the application code and allow your application to gracefully optimize its behavior for a variety of device configurations. Application Components Application components are the essential building blocks of an Android application. Each component is a different point through which the system can enter your application. Not all components are actual entry points for the user and some depend on each other, but each one exists as its own entity and plays a specific role—each one is a unique building block that helps define your application's overall behavior. There are four different types of application components. Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed. Here are the four types of application components: Activities An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work together to form a cohesive user experience in the email application, each one is independent of the others. As such, a different application can start any one of these activities (if the email application allows it). For example, a camera application can start the activity in the email application that composes new mail, in order for the user to share a picture. An activity is implemented as a subclass of Activity and you can learn more about it in the Activities developer guide. Services A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it. A service is implemented as a subclass of Service and you can learn more about it in the Services developer guide. Content providers 40 找毕业设计、项目源码、编程视频,就上码农网manong365 A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it). For example, the Android system provides a content provider that manages the user's contact information. As such, any application with the proper permissions can query part of the content provider (such as ContactsContract.Data) to read and write information about a particular person. Content providers are also useful for reading and writing data that is private to your application and not shared. For example, the Note Pad sample application uses a content provider to save notes. A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other applications to perform transactions. For more information, see the Content Providers developer guide. roadcast receivers B A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcasts—for example, to let other applications know that some data has been downloaded to the device and is available for them to use. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. For more information, see the BroadcastReceiver class. A unique aspect of the Android system design is that any application can start another application’s component. For example, if you want the user to capture a photo with the device camera, there's probably another application that does that and your application can use it, instead of developing an activity to capture a photo yourself. You don't need to incorporate or even link to the code from the camera application. Instead, you can simply start the activity in the camera application that captures a photo. When complete, the photo is even returned to your application so you can use it. To the user, it seems as if the camera is actually a part of your application. When the system starts a component, it starts the process for that application (if it's not already running) and instantiates the classes needed for the component. For example, if your application starts the activity in the camera application that captures a photo, that 41 找毕业设计、项目源码、编程视频,就上码农网manong365 activity runs in the process that belongs to the camera application, not in your application's process. Therefore, unlike applications on most other systems, Android applications don't have a single entry point (there's no main() function, for example). Because the system runs each application in a separate process with file permissions that restrict access to other applications, your application cannot directly activate a component from another application. The Android system, however, can. So, to activate a component in another application, you must deliver a message to the system that specifies your intent to start a particular component. The system then activates the component for you. Activating Components Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime (you can think of them as the messengers that request an action from other components), whether the component belongs to your application or another. An intent is created with an Intent object, which defines a message to activate either a specific component or a specific type of component—an intent can be either explicit or implicit, respectively. For activities and services, an intent defines the action to perform (for example, to "view" or "send" something) and may specify the URI of the data to act on (among other things that the component being started might need to know). For example, an intent might convey a request for an activity to show an image or to open a web page. In some cases, you can start an activity to receive a result, in which case, the activity also returns the result in an Intent (for example, you can issue an intent to let the user pick a personal contact and have it returned to you—the return intent includes a URI pointing to the chosen contact). For broadcast receivers, the intent simply defines the announcement being broadcast (for example, a broadcast to indicate the device battery is low includes only a known action string that indicates "battery is low"). The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from a ContentResolver. The content resolver handles all direct transactions with the content provider so that the component that's performing transactions with the provider doesn't need to and instead calls methods on the ContentResolver object. This leaves a layer of abstraction between the content provider and the component requesting information (for security). There are separate methods for activating each type of component: , You can start an activity (or give it something new to do) by passing an Intent to startActivity() or startActivityForResult() (when you want the activity to return a result). 42 找毕业设计、项目源码、编程视频,就上码农网manong365 , You can start a service (or give new instructions to an ongoing service) by passing an Intent to startService(). Or you can bind to the service by passing an Intent to bindService(). , You can initiate a broadcast by passing an Intent to methods like sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast(). , You can perform a query to a content provider by calling query() on a ContentResolver. For more information about using intents, see the Intents and Intent Filters document. More information about activating specific components is also provided in the following documents: Activities, Services, BroadcastReceiver and Content Providers. The Manifest File Before the Android system can start an application component, the system must know that the component exists by reading the application's AndroidManifest.xml file (the "manifest" file). Your application must declare all its components in this file, which must be at the root of the application project directory. The manifest does a number of things in addition to declaring the application's components, such as: , Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts. , Declare the minimum API Level required by the application, based on which APIs the application uses. , Declare hardware and software features used or required by the application, such as a camera, bluetooth services, or a multitouch screen. , API libraries the application needs to be linked against (other than the Android framework APIs), such as the Google Maps library. , And more Declaring components The primary task of the manifest is to inform the system about the application's components. For example, a manifest file can declare an activity as follows: ... 43 找毕业设计、项目源码、编程视频,就上码农网manong365 In the element, the android:icon attribute points to resources for an icon that identifies the application. In the element, the android:name attribute specifies the fully qualified class name of the Activity subclass and the android:label attributes specifies a string to use as the user-visible label for the activity. You must declare all application components this way: , elements for activities , elements for services , elements for broadcast receivers , elements for content providers Activities, services, and content providers that you include in your source but do not declare in the manifest are not visible to the system and, consequently, can never run. However, broadcast receivers can be either declared in the manifest or created dynamically in code (as BroadcastReceiver objects) and registered with the system by calling registerReceiver(). For more about how to structure the manifest file for your application, see The AndroidManifest.xml File documentation. Declaring component capabilities As discussed above, in Activating Components, you can use an Intent to start activities, services, and broadcast receivers. You can do so by explicitly naming the target component (using the component class name) in the intent. However, the real power of intents lies in the concept of intent actions. With intent actions, you simply describe the type of action you want to perform (and optionally, the data upon which you’d like to perform the action) and allow the system to find a component on the device that can perform the action and start it. If there are multiple components that can perform the action described by the intent, then the user selects which one to use. The way the system identifies the components that can respond to an intent is by comparing the intent received to the intent filters provided in the manifest file of other applications on the device. When you declare a component in your application's manifest, you can optionally include intent filters that declare the capabilities of the component so it can respond to intents from other applications. You can declare an intent filter for your component by adding an element as a child of the component's declaration element. For example, an email application with an activity for composing a new email might declare an intent filter in its manifest entry to respond to "send" intents (in order to send 44 找毕业设计、项目源码、编程视频,就上码农网manong365 email). An activity in your application can then create an intent with the “send” action (ACTION_SEND), which the system matches to the email application’s “send” activity and launches it when you invoke the intent with startActivity(). For more about creating intent filters, see the Intents and Intent Filters document. Declaring application requirements There are a variety of devices powered by Android and not all of them provide the same features and capabilities. In order to prevent your application from being installed on devices that lack features needed by your application, it's important that you clearly define a profile for the types of devices your application supports by declaring device and software requirements in your manifest file. Most of these declarations are informational only and the system does not read them, but external services such as Google Play do read them in order to provide filtering for users when they search for applications from their device. For example, if your application requires a camera and uses APIs introduced in Android 2.1 (API Level 7), you should declare these as requirements in your manifest file. That way, devices that do not have a camera and have an Android version lower than 2.1 cannot install your application from Google Play. However, you can also declare that your application uses the camera, but does not require it. In that case, your application must perform a check at runtime to determine if the device has a camera and disable any features that use the camera if one is not available. Here are some of the important device characteristics that you should consider as you design and develop your application: Screen size and density In order to categorize devices by their screen type, Android defines two characteristics for each device: screen size (the physical dimensions of the screen) and screen density (the physical density of the pixels on the screen, or dpi—dots per inch). To simplify all the different types of screen configurations, the Android system generalizes them into select groups that make them easier to target. The screen sizes are: small, normal, large, and extra large. The screen densities are: low density, medium density, high density, and extra high density. By default, your application is compatible with all screen sizes and densities, because the Android system makes the appropriate adjustments to your UI layout and image resources. However, you should create specialized layouts for certain screen sizes and provide specialized images for certain densities, using alternative layout resources, and by declaring in your manifest exactly which screen sizes your application supports with the element. 45 找毕业设计、项目源码、编程视频,就上码农网manong365 For more information, see the Supporting Multiple Screens document. Input configurations Many devices provide a different type of user input mechanism, such as a hardware keyboard, a trackball, or a five-way navigation pad. If your application requires a particular kind of input hardware, then you should declare it in your manifest with the element. However, it is rare that an application should require a certain input configuration. Device features There are many hardware and software features that may or may not exist on a given ndroid-powered device, such as a camera, a light sensor, bluetooth, a certain version A of OpenGL, or the fidelity of the touchscreen. You should never assume that a certain feature is available on all Android-powered devices (other than the availability of the standard Android library), so you should declare any features used by your application with the element. Platform Version Different Android-powered devices often run different versions of the Android platform, such as Android 1.6 or Android 2.3. Each successive version often includes additional APIs not available in the previous version. In order to indicate which set of APIs are available, each platform version specifies an API Level (for example, Android 1.0 is API Level 1 and Android 2.3 is API Level 9). If you use any APIs that were added to the platform after version 1.0, you should declare the minimum API Level in which those APIs were introduced using the element. It's important that you declare all such requirements for your application, because, when you distribute your application on Google Play, the store uses these declarations to filter which applications are available on each device. As such, your application should be available only to devices that meet all your application requirements. For more information about how Google Play filters applications based on these (and other) requirements, see the Filters on Google Play document. Application Resources An Android application is composed of more than just code—it requires resources that are separate from the source code, such as images, audio files, and anything relating to the visual presentation of the application. For example, you should define animations, menus, styles, colors, and the layout of activity user interfaces with XML files. Using application resources makes it easy to update various characteristics of your application without modifying code and—by providing sets of alternative resources—enables you to optimize your application for a variety of device configurations (such as different languages and screen sizes). 46 找毕业设计、项目源码、编程视频,就上码农网manong365 For every resource that you include in your Android project, the SDK build tools define a unique integer ID, which you can use to reference the resource from your application code or from other resources defined in XML. For example, if your application contains an image file named logo.png (saved in the res/drawable/ directory), the SDK tools generate a resource ID named R.drawable.logo, which you can use to reference the image and insert it in your user interface. One of the most important aspects of providing resources separate from your source code is the ability for you to provide alternative resources for different device configurations. For example, by defining UI strings in XML, you can translate the strings into other languages and save those strings in separate files. Then, based on a language qualifier that you append to the resource directory's name (such as res/values-fr/ for French string values) and the user's language setting, the Android system applies the appropriate language strings to your UI. Android supports many different qualifiers for your alternative resources. The qualifier is a short string that you include in the name of your resource directories in order to define the device configuration for which those resources should be used. As another example, you should often create different layouts for your activities, depending on the device's screen orientation and size. For example, when the device screen is in portrait orientation (tall), you might want a layout with buttons to be vertical, but when the screen is in landscape orientation (wide), the buttons should be aligned horizontally. To change the layout depending on the orientation, you can define two different layouts and apply the appropriate qualifier to each layout's directory name. Then, the system automatically applies the appropriate layout depending on the current device orientation. For more about the different kinds of resources you can include in your application and how to create alternative resources for various device configurations, see the Application Resources developer guide. 47 找毕业设计、项目源码、编程视频,就上码农网manong365 中文翻译 在Java编程语言编写的Android应用程序的Android的SDK工具编译代码以及与任何数据和到一个Android的包,一个归档文件档案资源的.apk后缀,所有的在一个单一的代码.apk文件被认为是一个应用程序,是Android的文件,供电设备来安装应用程序。 一旦安装在设备上,每个Android应用程序的生命在它自己的安全沙箱: 而Android操作系统是一个多用户Linux系统中,每个应用程序是一个不同的用户。 默认情况下,每个应用程序的系统分配一个唯一的Linux用户ID(该ID仅用于由系统是未知的应用程序),系统设置所有的应用程序中的文件权限,以便只有用户ID分配给该应用程序可以访问它们。 每个进程都有它自己的虚拟机(VM),因此应用程序的代码在从其他应用程序隔离运行。 默认情况下,每个应用程序运行在它自己的Linux进程。Android的启动过程时,应用程序的任何组件需要被执行,然后关闭该进程时,它不再需要或恢复时,系统必须为其他应用程序的内存。 这样一来,Android系统实现了最小特权原则,也就是说,每个应用程序,默认情况下,只能访问的组件,它需要做的工作,没有更多,这将创建一个非常安全的环境,使应用程序无法访问的,这就是它没有给予许可制度的部分。 但是,有一个应用程序的方法与其他应用程序和应用程序访问系统服务的数据: 这有可能为两个应用程序安排共享相同的Linux用户ID,在这种情况下,它们能够相互访问的文件。为了节约使用相同的用户ID系统资源,应用程序还可以安排运行在相同的Linux进程和共享同一个VM(应用也必须使用相同的证书签名)。 应用程序可以请求访问权限,如用户的联系人,短信,可安装存储(SD卡),摄像头,蓝牙等设备的数据,所有应用程序的权限必须由用户在安装时授予。这涵盖了基本就如何Android应用程序在系统中存在这个文件的其余部分向您介绍: 框架的核心组件定义应用程序。 清单文件中声明组件和应用程序所需的设备功能。 资源是从应用程序代码分开,并允许您的应用程序正常优化的设备配置各种其行为。 应用程序组件(Application Components) Android的核心功能之一就是一个应用程序可以使用其它应用程序的元素(如果那个应用程序允许的话)。比如说,如果你的应用程序需要一个图片卷动列 表,而另一个应用程序已经开发了一个合用的而又允许别人使用的话,你可以直接调用那个卷动列表来完成工作,而不用自己再开发一个。你的应用程序并没有吸纳 或链接其它应用程序的代码,它只是在有需求的时候启动了其它应用程序的那个功能部分。 为达到这个目的,系统必须在一个应用程序的一部分被需要时启动这个应用程序,并将那个部分的Java对象实例化。与在其它系统上的应用程序不同,Android应用程序没有为应用准备一个单独的程序入口(比如说,没有main()方法), 而是为系统依照需求实例化提供了基本的组件。 48 找毕业设计、项目源码、编程视频,就上码农网manong365 共有四种组件类型: 活动(Activities) 一个 activity 代表用户界面的一个独立屏幕。例如,一个邮件应用程序应该有一个activity用于显示新邮件列表,另一个activity用于撰写一封邮件,还有一个activity用于读取邮件。尽管所有activitie协同工作以构成邮件应用程序的用户体验,但彼此之间相对独立。应次,不同的应用程序能够从任何一个activity启动 (只要邮件应用程序允许)。例如,用户需要分享一张照片,一个拍照应用程序能够启动邮件应用程序的activity 。 activity 是一个实现了 Activity 的子类,你可以在 Activities 开发者指导部分了解更多。 服务(Services) service 是在后台运行,执行长时间操作或者执行远程操作。service不提供用户界面。例如,当用户在另一个应用程序时,一个service可在后台播放音乐,或者是从网络上获取数据,而不阻断用户与当前activity的交互。其他组件,比如一个activity,为了与该service互动,可以启动或者 绑定它。 service 是一个实现了Service 的子类,你可以在 Services 开发者指导部分了解更多。 内容提供者(Content providers) 内容提供者将一些特定的应用程序数据供给其它应用程序使用。数据可以存储于文件系统、SQLite数据库或其它方式。内容提供者继承于ContentProvider 基类,为其它应用程序取用和存储它管理的数据实现了一套标准方法。然而,应用程序并不直接调用这些方法,而是使用一个ContentResolver 对象,调用它的方法作为替代。ContentResolver 可以与任意内容提供者进行会话,与其合作来对所有相关交互通讯进行管理。 参阅独立的内容提供者Content Providers 章节获得更多关于使用内容提供者的内容。 每当出现一个需要被特定组件处理的请求时,Android会确保那个组件的应用程序进程处于运行状态,或在必要的时候启动它。并确保那个相应组件的实例的存在,必要时会创建那个实例。 广播接收器(Broadcast receivers) 广播接收器是一个专注于接收广播通知信息,并做出对应处理的组件。很多广播是源自于系统代码的??比如,通知时区改变、电池电量低、拍摄了一张照片或者用户改变了语言选项。应用程序也可以进行广播??比如说,通知其它应用程序一些数据下载完成并处于可用状态。 应用程序可以拥有任意数量的广播接收器以对所有它感兴趣的通知信息予以响应。所有的接收器均继承自BroadcastReceiver基类。 广播接收器没有用户界面。然而,它们可以启动一个activity来响应它们收到的信息,或者用NotificationManager来通知用户。通知可以用很多种方式来吸引用户的注意力??闪动背灯、震动、播放声音等等。一般来说是在状态栏上放一个持久的图标,用户可以打开它并获取消息。 Android系统设计的一个独特方面是任何的一个程序都可以启动另一程序的组件。比如,你想让你的程序可以使用照相机拍照,如果已经有了实现这种功能的程序并且你你的程序能使用它(有权限),那么你就没有再要再写一个新的Activity来实现这个功能。你的程序不需要包含或者链接这个拍照程序。相反,你只需要在你的程序中打开这个拍照程序中的实现拍照功能的Activity。当拍完之后,拍好的照片甚至会自动返回给 49 找毕业设计、项目源码、编程视频,就上码农网manong365 你的程序。者对于用户来说,就好像是想拍照功能的程序就是你的这个程序的一部分一样。 当系统启动一个组件之后,如果这个组件所在的程序之前没有运行的话,系统会自动开始这个程序的进程,并初始化这个组件所需要的相关类。比如,你的程序开启了一个拍照功能程序的Activity,这时系统会启动这个Activity所在的程序,所以这个Activity运行在拍照功能的程序当中,而不是在你的程序中。所以,不像其他操作系统的中的程序一样,Android程序没有一个单独的入口点(比如没有我们常见的main()函数)。 因为系统中的程序运行在自己的独立进程中,并且程序中的文件都有自己的限制其他程序访问的权限,所以,你的程序不能直接激活其他程序中的组件。但是Android系统就可以。具体是这样的实现的,为了激活(activate)其他程序中的组件,你必须向系统发送一个消息来详细说明你要启动其他组件的意图,这样系统才会为你激活这个组件。 激活组件(Activating Components) 四大组件中的三个组件——activities、services和broadcast receiver——是由一种叫intent的异步消息来激活的。这些intents在运行时(runtime)将这些属于你的程序或不同程序的单独的组件绑定在一起(bind),你可以把这些intents看作是需要其他组件的action的messengers。 一个intent就是一个Intent对象,这个intent定义了一种可以激活(activate)某个特定组件或者某种特定类型的组件,这两种情况分别对应两种intent的定义方式或者显示的或者隐式的。 对于activities和services,一个intent定义了要执行的操作(action)(比如,要“view”或者“send”什么)和要操作的数据的URI。比如,一个intent可能会为一个activity传递一个请求来展示一张图片或者打开一个网页。有时,你可以启动一个activity来得到返回的结果,在这个例子中这个activity的返回的结果也是一个Intent(比如,你可以发送一个intent让用户选择一个personal contact并返回给你——这个返回的intent就包含了一个指向用户选择的联系人的URI)。(关于activity和service的启动方式,下面将介绍。) 对于广播接收者来说,intent只是简单的定义了要广播的内容(比如,一个用以表明电池电量很低的广播仅包含了一个表明电池电量很低的字符串)。 最后一种组件类型content provider并不是由intent来激活的(activate)。而是由接收到ContentResolver的请求时激活的。 它们都各自有自己的方法来激活相应的组件: , 你可以通过传递一个Intent给startActivity()或startActivityForResult()启动一个activity(或者给他一些新的要做的内容)。使用startActivityForResult()你将得到一个返回结果。 , 你可以通过传递一个Intent给startService()来start一个service(或者给一个正在运行的service一些新的指令(instructions))。或者你可以通过把一个Intent传递给bindService()来绑定一个service。 , 你可以通过传递一个Intent给诸如sendBroadcast()、sendOrderedBroadcast()或者sendStickyBroadcast()等方法来初始化一个广播。 , 你可以通过调用ContentResolver的query()方法来执行一次content provider的查询操作。 50 找毕业设计、项目源码、编程视频,就上码农网manong365 更多的关于intent的内容,可以参看文档中的Intents and Intent Filters。更多的关于激活特定组件的内容可以参看文档中的:Activities、Services、BroadcastReceiver、Content Providers。 关于Manifest文件(The Manifest File) 在Android系统可以启动一个应用程序组件之前,Android系统必须通过读取这个程序的AndroidManifest.xml(即manifest文件)文件来确定要启动的组件存在。你的程序必须在这个manifest文件声明用到的所有的组件,并且这个manifest文件必须在项目的根目录下。 另外,这个manifest文件还声明一些其他的东西,比如: , 确定这个程序需要的所有权限,比如Internet访问权限或者读取用户联系人权限。 , 声明这个运行这个程序所需要的最低API版本,这个可以根据开发该程序所使用的API版本。 , 声明该程序所需要的硬件或软件特征(features),比如照相机、蓝牙服务或者多点触屏。 , 声明该程序需要链接(link against)的API库(不是Andorid的framework APIs),比如Google Maps library。 , 等等。 组件声明 Manifest文件的首要任务就是通知系统关于程序中要使用的组件。比如,一个manifest文件可以用如下的方式来声明一个activity: [java] view plaincopy 1. 2. 3. 4. 6. 7. ... 8. 9. 元素中,android:icon属性用于指定一个用于标示该程序的icon。 51 找毕业设计、项目源码、编程视频,就上码农网manong365 在元素中,android:name属性用于确定这个扩展自Activity的子类的全路径名,android:label属性用于标示这个activity的对于用户可见的label。 你必须要用以下方式来声明你的程序组件: , activities:标签 , services:标签 , broadcast receiver:标签 , content providers:标签 如果程序中用到activities、services和content providers,你没有在manifest文件中声明,那么这些组件将不会被系统知道,结果就是你的程序不能运行。然而,broadcast receiver既可以在manifest文件中声明也可以在代码中动态创建(BroadcastReceiver),并通过调用registerReceiver()在系统中注册。 更多关于怎样为你的程序构建manifest文件,请参看文档The AndroidManifes.xml 文件。 声明组件的能力 正如在上面Activating Components中讨论的那样,你可以使用一个Intent来启动activities、services和broadcast receiver。你可以通过在intent中注明目标组件的名字(使用的是组件的类名)来显示的启动组件。然而,intents真正强大的地方在与关于intent的actions的概念。通过intent的actions,你可以简单的描述你要执行的操作的类型(并且可以有选择的描述你要处理的数据),可以允许系统在device中找到这个组件并启动它。如果有多个组件可以执行intent中描述的action,这时用户就可以选择一个来执行。 系统可以识别能对某intent做出反应的方式是通过将接收到的intent和设备中其他程序的manifest文件的intent filters进行比较实现的。 当你在程序的manifest文件中声明一个组件之后,你可以有选择包含intent filters,这些intent filters表明了组件对接收自其他程序的intent做出反应的能力(capabilities)。你可以通过添加一个元素作为a child of the component's declaration element 来为你的程序声明一个intent filter。 比如,在一个邮件程序中的一个activity可以编写新的邮件,这样的话你就需要在manifest文件中来声明一个intent filter来对“发送”intent响应(为了发送邮件)。这样,在你的程序中,一个activity就可以创建一个发送intent(ACTION_SEND),这样当你调用startaActivity()时,系统就会匹配邮件程序中的发送activity并启动它。 更多关于创建intent filters的内容,可以参看Intents and Intent Filter文档。 声明运行程序所需的条件 Andorid系统可以支持很多不同的设备,并且这些设备的性能特征并不相同。为了防止你的程序被安装在不能正常运行你的程序的较低android系统版本上,通过在manifest文件中声明你的程序支持的设备和软件,便变得尤其重要起来。大多数的这些声明仅是一些信息,而系统并不会读取它们,但是其他的服务比如Android Market却会阅读这些声明来帮助通过通过自己的设备搜索软件的用户过滤软件。 比如,你的程序需要照相机,并且使用的Android2.1的APIs,那么你就必须在你的manifest文件中声明这些需要。这样的话,在Android Market上,没有照相机或者Android系统版本低于2.1将不能安装你的程序。 然而,如果你的程序不需要照相机,你仍可以声明你需要照相机。这种情况下,你的程序必须在运行时做一下检查,来检查这个设备是否含有照相机,如果没有照相机可用,则系统将会使使用照相机的相关程序不能用。下面是一些你在设计和开发你的程序 52 找毕业设计、项目源码、编程视频,就上码农网manong365 时,必须要考虑的关于设备的一些重要方面: 屏幕大小和分辨率: 为了根据屏幕的类型进行分类,Android定义了两个特征:屏幕大小和分辨率。 屏幕尺寸有: 小,中,大,超大; 屏幕分辨率类型:低分辨率,中分辨率,高分辨率,超高分辨率; 默认情况下,你的程序可以兼容所有的屏幕尺寸和分辨率,因为Android系统对你的程序的UI布局和image资源做了适当的调整。 输入方式: 很多设备有不同类型的输入方式,比如键盘、轨迹球、五位元导航。如果你的程序需要某特定形式的输入方式,则你必须在manifes文件中使用 标签来声明。不过这种情况是比较少的。 设备配置: 有许多硬件或软件并不全在Android系统的设备上,比如,一个照相机、光线传感器、某个版本的 OpenGL,或者屏幕的保真度(fidelity)。你在任何条件下都不能假定Android设备具备某种特性(feature)(当然得除掉Android标准库的情况),所以如果你的程序使用了某feature,则你必须使用标签来声明。 不同地Android平台设备通常运行不同版本的 Android ,比如 Android 1.6 或者 Android 2.3。每个后续版本通常包含之前版本所不支持的新增 API。 In order to indicate which set of APIs are available, 每个平台版本对应一个 API Level (例如, Android 1.0 对应于 API Level 1 ,Android 2.3 对应于 API Level 9)。如果你使用任何在 1.0 版之后平台新增的 API,你应该使用元素声明最低 API Level 是包含这些 API的。 为你的应用程序声明所有这些要求至关重要,因为,当你在 Android Market 上发布你的应用程序时,Market 使用这些声明来过滤该应用程序是否对于每台设备可用。 这样,你的应用程序仅对能够满足你的应用程序要求的设备可用。 应用程序资源(Application Resources) 一个应用程序不仅仅由代码组成——它需要区别于源代码的资源,比如图片,音频文件,以及任何与应用程序视觉呈现相关联的内容。例如,你应该使用 XML 文件定义动画,菜单,风格,颜色,以及 activity 用户界面的布局。 使用应用程序资源文件,可以更容易地更新你的应用程序的特性而无需修改代码,并且 — 通过提供多套可替换资源文件 — 使您能够针对各种设备配置优化你的应用程序(比如不同语言或屏幕大小)。 对于你的安卓工程里面包含的每一项资源, SDK 构建工具定义一个唯一的正整数 ID 标识符,你可以使用该标识符从你的应用程序代码中或者从XML文件中定义的其他资源中特指该资源。例如,如果你的应用程序中包含一个名为 logo.png 图片文件(保存在 res/drawable/ 文件夹里), SD工具会生成一个资源 ID 命名为 R.drawable.logo,你可以使用该 ID 特指这张图片并插入你的用户界面中。 将资源提供工作同你的源代码分隔开来最重要的原因之一是能够使您为不同的设备配置提供可替换的资源文件。例如,在 XML 中定义 UI 字符串,你可以将这些字符串翻译成其他语言并保存在特定的文件夹中。然后,基于语言 qualifier / 修饰词 你添加资源文件夹名称 (比如 res/values-fr/ 对应于法语字符串) 以及用户语言设置, Android 系统会给你的 UI 提供适当的语言字符串。 53 找毕业设计、项目源码、编程视频,就上码农网manong365 对于你的可替代资源,Android 支持许多不同的 qualifiers / 修饰符 。修饰符是包含在你的资源文件夹名称中的一个短字符串,以便界定哪些设备配置可使用这些资源。 另一个例子,对于不同的设备屏幕和大小,你应当为你的 activities 创建不同的布局。例如,当设备屏幕是纵向的 (高),你可能希望一个按钮垂直排列的布局,但当屏幕是横向的(宽),按钮应当水平排列。为了根据方向调整布局,你可以定义两个不同的布局文件并给每个布局文件夹提供适当的修饰符。这样,系统会根据特定的设备方向自动为其提供适当的布局。 54
本文档为【Android个性闹钟计算机毕业设计论文】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_153723
暂无简介~
格式:doc
大小:276KB
软件:Word
页数:76
分类:工学
上传时间:2017-09-18
浏览量:183