在启动活动未知意向标志 [英] Unknown Intent Flag on Launcher Activity

查看:258
本文介绍了在启动活动未知意向标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动 launchmode =singleInstance,它是发射活动应用程序中。现在,我想能够检测到标志我的活动已/将被推出,但我找不到标志身份证上的的意图 标志 S =htt​​p://developer.android.com/reference /android/content/Intent.html相对=nofollow>记载页;这是标志

 旗标识的字符串版本是270532608
 

和字符串形式的意图是

  04-25 20:18:57.061:V / logtag(1665):意向{行动= android.intent.action.MAIN
        猫= [android.intent.category.LAUNCHER] FLG = 0x10200000 CMP =<过滤> }
 

应用程序第一次启动时,系统调用我的活动标志 = Intent.FLAG_ACTIVITY_NEW_TASK 或字符串版本= 268435456 (应该如此),但是当我退出程序,并开始一次从我得到的发射更多而不是previous标志位 0x10200000

  

所以我的问题是,谁能告诉我什么旗,这是?

     

为什么我的活动被称为呢?

     

和是否有来自我的活性可能与不同的标志除了未知1&安培触发发射任何其他实例; 0x10200000?

解决方案

这是的标志的组合:

 公共静态最终诠释FLAG_ACTIVITY_NEW_TASK = 0x10000000处;
 

 公共静态最终诠释FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
 

0x10000000处是268435456.
的十六进制 0x00200000是2097152.
的十六进制 如果添加了这些数字,你就会得到:
0x10200000,这对于270532608.
十六进制符号

所以第一次启动应用程序时,你只能 FLAG_ACTIVITY_NEW_TASK ,但第二次,你也将获得 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED 。这仅仅是一个按位或操作。 要检查你需要的标志是活动的,你可以做一个位与这样的:

 布尔hasNewTaskFlag =(FLG&安培; FLAG_ACTIVITY_NEW_TASK)!= 0;
 

I have an Activity with launchmode = "singleInstance" and it is the launcher Activity of the app. Now I am trying to detect which Flag my Activity was/will be launched with, but I can not find the flag id with the Intent Flags on the documented page; this is the flag

String version of the Flag id is 270532608

and String version of the Intent is

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

when the application first starts, the system calls my Activity with this Flag = Intent.FLAG_ACTIVITY_NEW_TASK or string version = 268435456 (which it should) but when I quit the app, and start it once more from the launcher I get this flag 0x10200000 instead of the previous flag

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?

解决方案

It's a combination of the flags:

public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;

and

public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;

0x10000000 is the hexadecimal notation for 268435456.
0x00200000 is the hexadecimal notation for 2097152.
If you add these numbers, you get:
0x10200000, which is the hexadecimal notation for 270532608.

So the first time you start your app, you just get FLAG_ACTIVITY_NEW_TASK, but the second time you will also get FLAG_ACTIVITY_RESET_TASK_IF_NEEDED. This is just a bitwise OR operation. To check if your desired flag is active, you can do a bitwise AND like this:

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

这篇关于在启动活动未知意向标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆