启动器上的未知意图标志 Activity

Unknown Intent Flag on Launcher Activity

我有一个 Activitylaunchmode = "singleInstance",它是应用程序的启动器 Activity。现在我正在尝试检测 Flag 我的 Activity was/will 是用哪个 Flag 启动的,但是我找不到带有 Intent Flag 的标志 ID documented page;这是旗帜

String version of the Flag id is 270532608

Intent 的字符串版本是

04-25 20:18:57.061: V/logtag(1665): Intent { act=android.intent.action.MAIN 
        cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=<filtered> }

当应用程序第一次启动时,系统用这个 Flag = Intent.FLAG_ACTIVITY_NEW_TASK 或字符串版本 = 268435456 (它应该)调用我的 Activity 但是当我退出应用程序,并再次从启动器启动它我得到这个标志 0x10200000 而不是以前的标志

so my question is can anyone tell me what Flag this is?

and why my activity is being called with it?

and are there any other instances from the launcher that my activity might be triggered with a different flag aside from the unknown one & 0x10200000?

首先,这个 flag 0x10200000 值在 Hexadecimal 中而不是 Decimal 这就是为什么如果您尝试 Google它。

这就是为什么您必须先 convert 将其转换为十进制。然后你会看到真正的 flag 值是 270532608 这意味着 在前一个任务上开始一个新任务

why my activity is being called with it?

因为您可能恢复了后台的实例(最近的应用程序列表)。不启动新实例

如果您想阅读有关此意图标志的更多信息,请单击 here

参考:Start new activity in window manager

它是标志的组合:

public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;

public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;

0x10000000 是 268435456 的十六进制表示法。
0x00200000 是 2097152 的十六进制表示法。
如果将这些数字相加,您将得到:
0x10200000,这是270532608的十六进制表示法。

所以第一次启动你的应用程序时,你只会得到 FLAG_ACTIVITY_NEW_TASK,但第二次你也会得到 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED。这只是一个按位或操作。 要检查您想要的标志是否处于活动状态,您可以像这样按位执行:

boolean hasNewTaskFlag = (flg & FLAG_ACTIVITY_NEW_TASK) != 0;