Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - Unknown Intent Flag on Launcher Activity

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...