zoukankan      html  css  js  c++  java
  • [Android Samples视频系列之ApiDemos] AppActivityReorder Activities

    1.Demo说明与演示

    该Demo主要演示FLAG_ACTIVITY_REORDER_TO_FRONT的使用

    效果图如下:

    2.视频讲解
    http://www.eyeandroid.com/thread-10717-1-1.html

    3.Demo分析

    Reorder Activities 示例有四个相关的Activitives: ReorderOnLaunch, ReorderTwo,ReorderThree, ReorderFour。其中ReorderOnLaunch为主Activity,ReorderOnLaunch启动ReorderTwo ,ReorderTwo启动 ReorderThree,ReorderThree启动 ReorderFour。 这时在Activity的”back stack”有如下状态:

    13_1.png

    ReorderFour 想再启动ReorderTwo, 这时用两种实现方法,一是在 RecordFour之上再启动一个新的 ReorderTwo ,这是startActivity的缺省行为。这是因为在AndroidManifest.xml

    <activity android:name=”.app.ReorderTwo” />
    <activity android:name=”.app.ReorderThree” />
    <activity android:name=”.app.ReorderFour” />

    .app.RecordTwo没有定义任何这个Intent的Flag。 比如有 FLAG_ACTIVITY_NEW_TASK,FLAG_ACTIVITY_CLEAR_TOP,FLAG_ACTIVITY_SINGLE_TOP,在这些情况下 Android将根据不同Flag设置来决定启动RecordTwo的方法,具体在后面的例子会有介绍。

    在Reorder Activities例子中,是将“Back Stack”中的ReorderTwo移到栈顶,方法是在启动Intent时设置Intent.FLAG_ACTIVITY_REORDER_TO_FRONT。如果设置了FLAG_ACTIVITY_REORDER_TO_FRONT表示将“Back Stack”中指定的Activity移动到栈顶。

     
    1. Intent intent = new Intent(ReorderFour.this, ReorderTwo.class);  
    2. intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);  
    3. startActivity(intent);  

    此时栈如下图所示:

    13_2.png



  • 相关阅读:
    洛谷 2574 XOR的艺术
    洛谷 1774 最接近神的人
    洛谷 3398 仓鼠找sugar 【模板】判断树上两链有交
    洛谷 2440 木材加工
    洛谷 1824 进击的奶牛
    洛谷 1873 砍树
    洛谷 1577 切绳子
    51nod1485 字母排序
    51nod1055 最长等差数列
    51nod1128 正整数分组V2
  • 原文地址:https://www.cnblogs.com/eyeandroid/p/2790053.html
Copyright © 2011-2022 走看看