[sg简单应用] poj 1082 Calendar Game

这一篇文章专门整理一下研究过的Android面试题,内容会随着学习不断的增加,如果答案有错误,希望大家可以指正

1.简述Activity的生命周期

当Activity开始启动的时候,首先调用onCreate(),onStart(),onResume()方法,此时Activity对用户来说,是可见的状态

当Activity从可见状态变为被Dialog遮挡的状态的时候,会调用onPause()方法,此时的Activity对用户可见,但是不能相

应用户的点击事件

当Activity从可见状态变为被其他的Activity完全覆盖或者是点击Home进入后台的时候,会依次调用onPause(),onStop()方法,如果在这个期间,系统内存不足,导致Activity被回收的话,还会调用onDestory()方法

当Activity从被Dialog遮挡的状态恢复的时候,会调用onResume()方法,从而恢复可以点击的状态

当Activity从被其他Activity遮挡或者是进入后台状态恢复,而且没有被系统回收的时候,会依次调用onRestart(),onStart(),onResume(),恢复到可以与用户进行交互的状态

当Activity从被其他Activity遮挡或者进入后台,而且被系统回收的时候,相当于重新打开一个Activity,既调用onCreate(),onStart(),onResume()方法,从而可以与用户进行交互

2.Intent启动Activity有几种方式,如何实现?

Intent启动Activity有两种方式,分别为显式意图,隐式意图

第一种,显示意图的实现。

	Intent intent = new Intent(this,OtherActivity.class);
	startActivity(intent);

显式意图还有另外一种形式

	Intent intent = new Intent();
	ComponentName component = new ComponentName(this, OtherActivity.class);
	intent.setComponent(component);
	startActivity(intent);

其实这两种形式其实是一样的,我们看一下Intent构造函数的代码

	public Intent(Context packageContext, Class<?> cls) {
        	mComponent = new ComponentName(packageContext, cls);
    	}

这样我们就一目了然了,其实我们经常使用的Intent的构造方法是第二种方式的简化版

第二种,是隐式意图的实现。

首先我们看一下隐式意图的调用方式

 	Intent intent = new Intent();
	intent.setAction("other");
	startActivity(intent);

隐式意图是通过setAction来进行区分到底跳转到哪一个界面,那么我们肯定要在需要跳转的页面设置一标志,我们需要在AndroidManifest.xml中对这个进行设置

 <activity android:name="com.example.lifecicledemo.OtherActivity" >
            <intent-filter>
                <action android:name="other" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

这样当我们使用setAction的时候,就可以知道我们到底是想跳转到哪一个页面了。

[sg简单应用] poj 1082 Calendar Game

时间: 2024-08-02 09:43:10

[sg简单应用] poj 1082 Calendar Game的相关文章

poj 1079 Calendar Game(博弈论 SG)

Calendar Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2519    Accepted Submission(s): 1438 Problem Description Adam and Eve enter this year's ACM International Collegiate Programming Co

POJ - 2080 Calendar

题意:求2000.1.1(周六)过n天后,是哪年哪月哪日星期几 思路:看到过好多次了这种题,细心点模拟就是了 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char w[7][10]={"Sunday", "Monday", "Tuesday", &

Poj Maya Calendar

http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64607 Accepted: 19908 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

转载:poj题目分类(侵删)

转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K–0.50K:中短代码:0.51K–1.00K:中等代码量:1.01K–2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348

poj题库分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目(转)

http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (

Poj 题目分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目分类(转)

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea