Intent的几种Flag的不同

冬天有点冷,不想写博客。

研究下Intent的几种Flag的不同:

1,FLAG_ACTIVITY_CLEAR_TOP:会清理掉目标activity栈上面所有的activity

Intent intent = new Intent(this, B.class);    
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);   
startActivity(intent);

2,FLAG_ACTIVITY_BROUGHT_TO_FRONT:创建目标activity,且位于栈顶

Intent intent = new Intent(this, B.class);    
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);   
startActivity(intent);

3,FLAG_ACTIVITY_REORDER_TO_FRONT:如果目标activity存在栈中,将其置顶

Intent intent = new Intent(this, B.class);    
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);   
startActivity(intent);

4,FLAG_ACTIVITY_NEW_TASK:创建新的activity实例

Intent intent = new Intent(this, B.class);    
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
startActivity(intent);

 

posted @ 2016-01-22 09:23  西北野狼  阅读(331)  评论(0编辑  收藏  举报