大连交通大学软件毕业设计系列-外文翻译_第1页
大连交通大学软件毕业设计系列-外文翻译_第2页
大连交通大学软件毕业设计系列-外文翻译_第3页
大连交通大学软件毕业设计系列-外文翻译_第4页
大连交通大学软件毕业设计系列-外文翻译_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

大连交通大学2012届本科生毕业设计(论文)外文翻译 Application Fundamentals Abstract: Android applications are written in the Java programming language and the application components have four types of application components.BeFore the Android system can start an application component, the system must know that the component exists by reading the applications AndroidManifest.xml file (the manifest file). An Android application is composed of more than just codeit requires resources that are separate from the source code, such as images, audio files, and anything relating to the visual presentation of the application. Key words: Java; application components; manifest; source; From: Android applications are written in the Java programming language. The Android SDK tools compile the codealong with any data and resource filesinto an Android package, 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 applications 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 applications components need to be executed, then shuts down the process when its 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: 1 Its possible to arrange For two applications to share the same Linux user ID, in which case they are able to access each others 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 users 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. 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 roleeach one is a unique building block that helps define your applications 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. 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. Content providers 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 users 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. Broadcast receivers A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the systemfor example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcastsfor 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 dont 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. A unique aspect of the Android system design is that any application can start another applications component. For example, if you want the user to capture a photo with the device camera, theres probably another application that does that and your application can use it, instead of developing an activity to capture a photo yourself. You dont 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 its 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 activity runs in the process that belongs to the camera application, not in your applications process. Therefore, unlike applications on most other systems, Android applications dont have a single entry point (theres 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. The Manifest File Before the Android system can start an application component, the system must know that the component exists by reading the applications 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 applications components, such as: Identify any user permissions the application requires, such as Internet access or read-access to the users 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 applications components. For example, a manifest file can declare an activity as follows: . 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(). Application Resources An Android application is composed of more than just codeit 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 andby providing sets of alternative resourcesenables you to optimize your application for a variety of device configurations (such as different languages and screen sizes). 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 directorys name (such as res/values-fr/ for French string values) and the users 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 devices 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 layouts directory name. Then, the system automatically applies the appropriate layout depending on the current device orientation. 应用程序基础 摘要: Android应用程序使用Java语言做为开发语言而且它拥有四种组件类型。因为Android系统在启动一个应用程序组件之前,必须知道那些组件是存在的。所以,应用程序会在一个manifest文件中声明它的组件。这个应用程序文件包括应用程序的代码、文件以及其它资源。 关键字: Java语言; 应用组件; manifest文件; 资源; 来源: Android应用程序使用Java语言做为开发语言。aapt工具把编译后的Java代码连同其它应用程序需要的数据和资源文件一起打包到一个Android包文件中,这个包文件使用.apk做为自己的扩展名,这个包文件是分发应用程序并安装到移动设备的媒介,用户只需下载并安装此包文件到他们的设备即可。每一个.apk文件中的所有代码都被认为是一个应用程序。 这些应用程序一旦被安装到设备上后,它们都运行在于它们自己的安全沙箱中: Android操作系统是一个多用户的Linux系统,并且在Android操作系统中每一个 应用程序都是一个不同的用户。 默认情况下,系统的每个应用程序都会被分配一个唯一的Linux用户ID(ID只有 系统知道并且其他应用程序是未知的)。系统中的每一个应用程序都被设置了 权限,只有在获得了他们的权限的情况下才能访问他们。 每个进程都运行于自己的虚拟机中。所以每一个应用程序实际上与其它应用程 序彼此间是相互独立的。 默认情况下,每一个应用程序均运行于自己的Linux进程中。当应用程序中的任 意应用程序需要执行时,Android系统就会为其启动一个进程,而当不再需要此进程或者其它应用程序又需要系统资源时,就会关闭这个进程。 这样一来,Android系统就实现了最小特权原则。也就是说,每个应用程序在默认情况下只能访问自己的组件和做自己的工作。这样将创建一个非常安全的环境,在其中的每一个应用程序在没有获准的情况下是不能访问系统的其他部分的。 当然,也有其它的方法使得这些应用程序同样能被其他的应用程序所访问: 可以安排另一个应用程序共享他们自己的Linux用户ID,在这种情况下,他们就 可以访问对方的文件。有时为了节省系统资源,具有相同用户ID的应用程序也 可以运行在同一个Linux进程中,并且共享一个虚拟机(这些应用程序必须拥 有相同的签署证书)。 应用程序可以通过请求访问权限来获取对用户的联系人信息、短信、SD数据存 储、摄像头、蓝牙等设备数据的操作。所有的权限都必须在应用程序被安装的 时候请求。 为了向您介绍一个应用程序在Android系统中是怎样存在的,下面我们将向您介绍一下几个方面的基础知识: 应用程序的核心框架。 应用程序的manifest文件 应用程序的资源。 应用程序框架 应用程序组件是一个Android应用程序的重要基石。每个组件都可以通过一个不同的角度进入到应用程序。并非所有的组件都为用户提供了实际入口点,但每一个作为自己的实体存在都起着特定的作用每一个都是一个独一无二的模块,它能帮助定义您的应用程序的整体行为。 一共有四种不同类型的应用程序组件。每个类型都有不同的作用,并且他们都有创建和销毁这些生命周期。 这里有四种类型的应用程序组件: Activities 一个activity组件代表一个用户界面的中的一个显示屏幕。例如,一个邮件应用程序可能会有一个活动来显示一系列新的邮件,另外一个活动用来撰写邮件,另外一个活动用来读取邮件。虽然这些activity一起工作,组成了用户使用的邮件应用程序,但是他们彼此间是相互独立的。因此,另外一个不同的应用程序也可以启动这些activity中的任何一个(如果这个邮件应用程序允许)。例如,一个摄像头应用程序就可以启动邮件应用程序中的activity来分享照片。 Services Service是长时间在后台运行或者可以进行远程操作的组件。Service不显示用户界面。例如,一个service可以在用户使用其他应用的时候在后台播放音乐或着在获取网络上的数据时不与用户的交互活动产生阻塞。另外的组件(例如一个activity 组件)可以启动一个service服务,并且可以让它运行或者与用户界面进行绑定。Content providers Content provider组件管理应用程序数据的共享设置。你可以将数据存储在文件系统中、SQLite 数据库中,网页中或者其它你的应用程序可以访问的持久存储位置。 通过content provider,其他的应用程序可以查询甚至修改存储的数据(如果 content provider允许)。例如,Android系统提供了content provider 来管理 用户的联系人信息。因此,任何有相应权限的应用程序都可以查询部分content provider来读取和写入某个人的信息。 Content providers同样对读取和写入应用程序的隐私数据而不是分享这些数据有着重要的作用。例如,记事本程序用content providers来保存数据。 Broadcast receivers Broadcast receiver是一个在全系统广播通知的组件。许多广播都来自系统例如一个广播宣布屏幕已经关闭,电池电力过低或者一张照片被捕获。应用程序也可以启动广播例如让其他的应用程序知道某些数据已经被下载并可以被他们使用。虽然广播接收器不显示用户界面,但是他们可以在广播事件发生时通过创建状态栏通知来提醒用户。不过,更常见的情况是,一个广播接收器只是其他组件的“门户”,并且他们做的工作量也非常少。例如,它可能启动一个service去执行基于事件的一些工作。 Android系统设计的独到之处在于任何应用程序都可以启动另外一个应用程序组件。例如,你想通过摄像头设备捕获一张图片,你可以通过你的程序使用其他应用程序去实现,而不需要去编写一个activity来捕获这张图片。你甚至都不需要使用摄像头应用程序的的代码,取而代之的是,你可以通过启动一个摄像头应用程序的activity来捕获一张图片。当完成后,图片就会返回到你

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论