(2)
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.
关于一个应用程序如何存在于系统的基础知识部分,以下文档将向你介绍:
用来定义你的应用程序的核心框架组件。
用来描述组件和应用程序设备属性的manifest文件。
可以被方便的用来配置并且与与应用程序代码独立开来的资源。
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.
活动
一个活动呈现一个用户交互的界面。例如,邮件应用程序可以有一个用来显示新邮件列表的活动,其他撰写邮件的活动,读邮件的活动。 因为这些一起工作的活动是为了在一个邮件应用程序中形成一个用户体验的集合,每个都相互独立。因此,一个不同的应用程序可以启动这些活动中的任意一个(如邮件应用程序允许的话)。