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. IDEA JSP项目构建及学习心得

    近期学习的东西比较杂乱,导致了很多东西都有些忘却.在这里记录一份心得. 简而言之JSP也就是Java代码在页面上的一种呈现方式,用于Web项目的前台展示. 在这里不做过多的阐述. MVC设计模式,Se ...

  2. ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS

    B. Om Nom and Dark Park Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  3. 机器学习(1):Logistic回归原理及其实现

    Logistic回归是机器学习中非常经典的一个方法,主要用于解决二分类问题,它是多分类问题softmax的基础,而softmax在深度学习中的网络后端做为常用的分类器,接下来我们将从原理和实现来阐述该 ...

  4. OpenVPN原理及实践文章收集(转)

    一.基本理论篇 vpn原理及实现--一般理论 vpn原理及实现--隧道的一种实现 vpn原理及实现--虚拟网卡构建vpn vpn原理及实现--tcp还是udp Linux平台VPN技术概论 Linux ...

  5. [置顶] Spring的自动装配

    采用构造函数注入,以及setter方法注入都需要写大量的XML配置文件,这时可以采用另一种方式,就是自动装,由Spring来给我们自动装配我们的Bean. Spring提供了四种自动装配类型 1:By ...

  6. 从零开始搭建linux下laravel 5.5所需环境(三)

    好的,我们已经安装好了nginx+mysql+php了,打开[ Laravel 5.5 文档 ] 快速入门 —— 安装配置篇 我们看到这里需要安装Composer,好的,我们现在就来安装Compose ...

  7. ios项目开发(天气预报项目):使用正则获取 weather.com.cn站点信息

    NSString *pattern = @"(?<=<td class=\"bigblod\">).*?(?=</td>)"; 2 ...

  8. Tasker to create toggle widget for ES ftp service -- Send Intent

    To perform this mission, Tap the tab "tasks" of Tasker, create a task as below.Task: (ES F ...

  9. hdu 1847 博弈基础题 SG函数 或者规律2种方法

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  10. OS X 10.10.4系统,命名为“Yosemite”(优胜美地)

    新版OS X 10.10.4系统,命名为“Yosemite”(优胜美地),拥有全新的界面设计及一些功能更新,下面一起来了解一下. 一.界面扁平化.进一步融入iOS功能 首先,OS X 10.10 Yo ...