An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.
An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and takes user focus. The back stack abides to the basic "last in, first out" queue mechanism, so, when the user is done with the current activity and presses the BACK key, it is popped from the stack (and destroyed) and the previous activity resumes. (The back stack is discussed more in the Tasks and Back Stack document.)
When an activity is stopped because a new activity starts, it is notified of this change in state through the activity's lifecycle callback methods. There are several callback methods that an activity might receive, due to a change in its state—whether the system is creating it, stopping it, resuming it, or destroying it—and each callback provides you the opportunity to perform specific work that's appropriate to that state change. For instance, when stopped, your activity should release any large objects, such as network or database connections. When the activity resumes, you can reacquire the necessary resources and resume actions that were interrupted. These state transitions are all part of the activity lifecycle.
The rest of this document discusses the basics of how to build and use an activity, including a complete discussion of how the activity lifecycle works, so you can properly manage the transition between various activity states.
更详细的说明,请查阅官方的相关文档。
Activity有那么的状态,主要是为了提高速度,因为在不同状态之间切换,需要回调不同方法
分享到:
相关推荐
Activity 详解 Activity 详解
### Android Activity 详解 在Android应用开发中,`Activity`是四大组件之一,它负责管理用户界面,并且是用户与应用程序交互的主要入口。一个应用程序通常包含多个Activity,它们通过特定的方式进行通信和交互。 ...
Android四大组件之Activity详解 Android四大组件中的Activity是最基本也是最重要的组件之一。Activity是用户与应用程序交互的入口点,负责处理用户的交互请求,并将结果返回给用户。今天,我们将深入探讨Activity...
**ViewPager加载Activity详解** ViewPager是Android开发中一个非常重要的组件,它主要用于实现界面间的滑动切换效果,使得用户可以通过左右滑动来浏览多个视图。在Android应用设计中,ViewPager通常与Fragment配合...
activity之间的传递数据的详解。代码简单易懂
### 详解 Android 的 Activity 组件 #### 概述 在Android开发中,`Activity`是四大组件之一,它是用户界面的基础单位,也是Android应用中最重要的组成部分之一。一个Android应用通常由多个`Activity`组成,每个`...
### Android四大组件之一的Activity详解 #### 一、Activity简介 **Activity** 是 Android 开发中的四大组件之一,它提供了一个界面供用户进行交互,以完成特定的任务。每个 Activity 都是一个可视化的屏幕,上面...
**一、Activity详解** Activity是用户与应用交互的窗口,代表屏幕上的一个可视界面。它的生命周期包括: 1. `onCreate()`:Activity创建时调用,用于初始化界面和数据。 2. `onStart()`:Activity开始变得可见,但...
### Android APK外部调用应用Activity详解 在Android开发中,应用程序之间通过Intent机制进行通信,这一特性使得一个应用可以启动另一个应用的组件(如Activity、Service等),从而实现跨应用的功能交互。本文将...
一、什么是Activity? 简单的说:Activity就是布满整个窗口或者悬浮于其他窗口上的交互界面。在一个应用程序中通常由多个Activity构成,都会在Manifestxml中指定一个主的Activity,如下设置 当程序第一次运行时...
### Activity详解 `Activity`是Android应用的核心组成部分,代表了用户可见的屏幕界面。一个`Activity`通常对应着用户界面上的一个独立任务或者功能。例如,登录界面、主屏幕或者设置页面等都可以是独立的`Activity`...
### 详解Android开发中的Activity组件 #### 概述 在Android开发中,`Activity`是四大组件之一,扮演着至关重要的角色。它负责提供用户界面并处理与用户的交互,每一个`Activity`通常对应一个屏幕。本文将深入探讨`...
### Android系统Package与Activity详解 #### 一、Package包 **Package** 在Android应用程序中扮演着至关重要的角色。它不仅定义了一个应用的基本单位,还确保了应用的独特性和可识别性。 1. **唯一性**: 每个...
门——Activity(一) Activity是什么: Activity作为Andorid的四大组件之一,为用户提供了一个界面,即我们能看到的界面。相当于一张画画用的纸,我们可以在上面画任何我们想要的内容。 Activity的创建: 就像我们...