(转)Android属性设置android:noHistory="true"
设置 android:noHistory="true"后,该Activity在statck中不留历史痕迹。默认的值是false。
举例说明,假设有三个Activity分别是:A,B,C。这三个Activity可以依次顺序启动下一个Activity,比如,在A中做一个Button,用户点击后跳转到B ; 同样,在B中也做一个Button,点击跳转到C。C不再做Button,只是一个用以演示的空壳Activity。
在AndroidManifest.xml中配置B的属性为:android:noHistory="true"
其他两个不做特别设置,仅仅作为一般的Activity处理。
可以观察到,A启动后,从A跳转到B,再从B跳转到C,进入C后,此时如果按返回键,将直接进入A,而不是B。简单的跳转逻辑路线:
A –> B –> C –> 按返回键 –> A
综上,可以这么理解android:noHistory="true"对Activity行为的影响:当该Activity屏幕不可见时,相当于Android系统调用Activity的finish()方法结束了该Activity。
实验代码:
A.java
package zhangphil.test; import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle; public class A extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); Button button = new Button(this);
button.setText("点击跳转到B");
final Context context = this;
button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
Intent intent = new Intent(context, B.class);
startActivity(intent);
}
}); setContentView(button);
}
}
B.java
package zhangphil.test; import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle; /**
* android:noHistory="true"
*
* */ public class B extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); Button button = new Button(this);
button.setText("点击跳转到C");
final Context context = this;
button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
Intent intent = new Intent(context, C.class);
startActivity(intent);
}
}); setContentView(button);
}
}
C.java
package zhangphil.test; import android.support.v7.app.ActionBarActivity;
import android.os.Bundle; public class C extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="zhangphil.test"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="22" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name=".A"
android:label="A" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity
android:noHistory="true" android:name=".B"
android:label="B" >
</activity> <activity
android:name=".C"
android:label="C" >
</activity> </application> </manifest>
(转)Android属性设置android:noHistory="true"的更多相关文章
- Android权限设置android.permission
android.permission.ACCESS_NETWORK_STATE: 允许程序访问有关GSM网络信息(Allows applications to access information a ...
- 【Android】设置android:maxLines="1"后,android:imeOptions="actionSearch"失效
android:singleLine在API LEVEL 3已经废弃,可以用android:maxLines="1"代替. 但是测试的时候发现设置android:maxLines= ...
- Android权限设置android.permission完整列表
android.permission.ACCESS_CHECKIN_PROPERTIES允许读写访问"properties”表在checkin数据库中,改值可以修改上传( Allows re ...
- [Android Pro] Android权限设置android.permission完整列表
android.permission.ACCESS_CHECKIN_PROPERTIES允许读写访问"properties”表在checkin数据库中,改值可以修改上传( Allows re ...
- Android动态设置android:drawableLeft|Right|Top|Bottom 并根据分辨率自适应
http://blog.sina.com.cn/s/blog_4b93170a0102e1m9.html //调用setCompoundDrawables时,必须调用Drawable.setBound ...
- Android textAppearance的属性设置及TextView属性详解
textAppearance的属性设置 android:textAppearance="?android:attr/textAppearanceSmall" android:tex ...
- Android Application Fundamentals——Android应用程序基础知识
Application Fundamentals--应用程序基础知识 Key classes--关键类 Activity Service BroadcastReceiver ContentProvid ...
- 关于设置android:imeOptions属性无效的解决办法
在对Android的EditText控件进行设置时,经常会限定一下输入法的属性,设置右下角为完成或者搜索等,一般都会想到android:imeOptions属性,但是仅仅这么设置通常是无效的,还要搭配 ...
- 简单分析android textview xml 的属性设置
android:ems 设置TextView的宽度为N个字符的宽度. 这样的好处就是,在定义编辑框空间输入多少字符的时候,可以根据固定的值设置编辑框宽度.保证边框和文字的宽度统一.android:ma ...
随机推荐
- SAP
http://www.itpub.net/thread-1328005-1-1.html http://blog.sina.com.cn/s/blog_4b75f26e0100b52a.html SA ...
- MFC学习 标签页与属性页及各常用控件使用
参考 http://blog.csdn.net/anye3000/article/details/6700023 CTabCtrl: BOOL CTabTestDlg::OnInitDialog() ...
- Linux下查看文件和文件夹大小(转)
觉得挺有用的,就转到了自己的博客里,方便以后查询: 转自:http://www.cnblogs.com/benio/archive/2010/10/13/1849946.html 当磁盘大小超过标准时 ...
- Solr数据库连接之多表关联
Solr环境配置好后,有很多时候我们需要把数据库里的数据添加到索引里,这时就需要配置跟数据库的连接,下面我们看配置的步骤. 1. 配置 solrconfig.xml (在slor 主目录 core ...
- Python安装Selenium3
概述 2016.10.13,Selenium3.0正式发布,官方说明如下: The major change in Selenium 3.0 is we're removing the origina ...
- 架构设计--逻辑层 vs 物理层
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 Layer 和Tier都是层,但是他们所表现的含义不同,Tier指的是软件系统中物理 ...
- AX2012全新的批处理方式
AX2009 的批处理操作我们是通过RunBaseBatch framework,我们所要做的事情就是继承RunBaseBatch class,实现里面该实现的方法来执行批处理. AX2012 的批处 ...
- Android ROM 备书
1. Android ROM 目录接口 我们经常说的刷ROM是刷系统的意思,但是ROM的原意并不是这样,ROM的全称是read only memory只读储存器,正因为它是“只读”的,而且系统文件通常 ...
- PL/SQL 导入excel表格到oracle数据表
通过使用PL/SQL 批量查询取数时,将excel中的每一列数据复制黏贴进新建的中间表,黏贴时会有贴歪的情况,也就是某些列会从第二第三行开始插入整列,导致数据乱掉,然后好像又不支持批量删除整列数据,所 ...
- MFC启动和关闭线程
1. 启动线程: CWinThread* AfxBeginThread( 线程函数,this ); 2.通常导致线程终止的两种情况是:控制函数退出或不允许线程完成运行.如果字处理器使用后台打印线程,若 ...