An activity can exist in essentially three states:

Resumed
The activity is in the foreground of the screen and has user focus. (This state is also sometimes referred to as "running".)
Paused
Another activity is in the foreground and has focus, but this one is still visible. That is, another activity is visible on top of this one and that activity is partially transparent or doesn't cover the entire screen. A paused activity is completely alive (the Activity object is retained in memory, it maintains all state and member information, and remains attached to the window manager), but can be killed by the system in extremely low memory situations.
Stopped
The activity is completely obscured by another activity (the activity is now in the "background"). A stopped activity is also still alive (the Activity object is retained in memory, it maintains all state and member information, but is not attached to the window manager). However, it is no longer visible to the user and it can be killed by the system when memory is needed elsewhere.

If an activity is paused or stopped, the system can drop it from memory either by asking it to finish (calling itsfinish() method), or simply killing its process. When the activity is opened again (after being finished or killed), it must be created all over.

Splash.java作用相当于一个Welcome page, 当程序开始的时候显示,显示过后就不再需要切换个主界面,但是这个welcome界面状态是purse / stop. 但是还是alive, 用户可以用回退键访问这个welcome界面。所以可以使用finish()来kill这个activity, 通常可以在onPurse()中做。

package com.example.thenewboston;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; public class Splash extends Activity{ @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash); ScheduledExecutorService timer = Executors.newSingleThreadScheduledExecutor();
timer.execute(new Runnable(){ @Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.example.thenewboston.MAINACTIVITY");
startActivity(openStartingPoint);
}
} });
} @Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
//Kill this acticity
finish();
} }

6. Activity life cycle的更多相关文章

  1. Activity初步,初学者必看

    Activity是什么? Activity是一个可与用户交互并呈现组件的视图.通俗说就是运行的程序当前的这个显示界面. 如果你还不明白,那么你写过HTML吗,它就好比一个网页.我们程序中的用户视图,都 ...

  2. 【Android开发-8】生命周期,Activity中打开另外一个Activity

    前言:生命中有很多人陪伴自己走过一生中的某段旅程,仅仅是有些人仅仅是某阶段出现,有些人却陪伴自己非常久.就像小学.中学.高中.大学,那些以前以为会长久拥有的,当经历过天涯各地地忙碌于生活,或如意.或失 ...

  3. activity 生命周期 http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for

    331down voteaccepted See it in Activity Lifecycle (at Android Developers). onCreate(): Called when t ...

  4. Cheatsheet: 2013 09.01 ~ 09.09

    .NET Multi Threaded WebScraping in CSharpDotNetTech .NET Asynchronous Patterns An Overview of Projec ...

  5. 喜闻乐见-Android应用的生命周期

    本文主要讲述了App的启动流程.Application的生命周期以及进程的回收机制. 在绝大多数情况下,每一个Android应用都在自己的Linux进程中运行.当需要运行某些代码时,进程就会被创建.进 ...

  6. Android 7.1.1 锁屏界面启动流程

    前几天遇到一个低概率复现锁屏界面不显示,仅仅显示状态栏的问题,跟了下锁屏界面启动显示的流程,在这分享下,也方便以后自己查看.前面简介了下Zygote启动流程, Zygote进程启动后会首先创建一个Sy ...

  7. 【起航计划 012】2015 起航计划 Android APIDemo的魔鬼步伐 11 App->Activity->Save & Restore State onSaveInstanceState onRestoreInstanceState

    Save & Restore State与之前的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 实现的UI类似,但 ...

  8. udacity android 学习笔记: lesson 4 part a

    udacity android 学习笔记: lesson 4 part a 作者:干货店打杂的 /titer1 /Archimedes 出处:https://code.csdn.net/titer1 ...

  9. udacity android 实践笔记: lesson 4 part a

    udacity android 实践笔记: lesson 4 part a 作者:干货店打杂的 /titer1 /Archimedes 出处:https://code.csdn.net/titer1 ...

随机推荐

  1. 51nod 1515 明辨是非 启发式合并

    1515 明辨是非 题目连接: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1515 Description 给n组操 ...

  2. Codeforces Beta Round #11 A. Increasing Sequence 贪心

    A. Increasing Sequence 题目连接: http://www.codeforces.com/contest/11/problem/A Description A sequence a ...

  3. UVALive 6257 Chemist's vows

    #include<iostream> #include<string.h> #include<stdio.h> #include<ctype.h> #i ...

  4. Codeforces Round #287 (Div. 2) B. Amr and Pins 水题

    B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  5. Slickflow.NET 开源工作流引擎基础介绍(二) -- 引擎组件和业务系统的集成

    集成流程引擎的必要性 业务过程的变化是在BPM系统中常见的现象,企业管理层需要不断优化组织架构,改造业务流程,不可避免地带来了业务流程的变化,企业信息系统就会随之面临重构的可能性.一种直接的方式是改造 ...

  6. xcode .h文件编译时 版本不正确

    在终端里面   执行下面的命令 rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache/*

  7. cuda并行编程之求解ConjugateGradient(共轭梯度迭代)丢失dll解决方式

    在进行图像处理过程中,我们常常会用到梯度迭代求解大型线性方程组.今天在用cuda对神秘矩阵进行求解的时候.出现了缺少dll的情况: 报错例如以下图: watermark/2/text/aHR0cDov ...

  8. Jenkins搭建.NET自动编译测试与发布环境

    本文地址: http://blog.csdn.net/wangjia184/article/details/18365553 操作系统Windows, 确保需要的.NET Framework已经安装 ...

  9. Delphi7下使用FastMM4

    1> 将文件Replacement BorlndMM DLL/Precompiled/for Delphi IDE/Performance/BorlndMM.dll,替换掉Delphi/Bin下 ...

  10. [Asp.net web api]缓存

    摘要 为了提高接口的性能,我们常做的优化就包括缓存,对经常访问但变化不大的数据进行缓存.或者使用http的缓存,减少请求的次数. web api缓存 在提供的api,我们也可以实现缓存,来减少访问的次 ...