Reputation: 105
I used this line of code to launch my app
intent.setFlags(805306368);
and it perfectly launches the app and resumes it if it is running in background. But what does the integer number 805306368 mean?
What does it do to resume my app if it is running.Does anyone know.
Upvotes: 1
Views: 3074
Reputation: 5543
805306368
is equivalent to 0x30000000
in hex and 0x30000000
is used to open the Intent
with the following flags :
Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP
So, its equivalent to use the above combination or 0x30000000
.
From Android docs FLAG_ACTIVITY_SINGLE_TOP, FLAG_ACTIVITY_NEW_TASK :
FLAG_ACTIVITY_SINGLE_TOP = 0x20000000
FLAG_ACTIVITY_NEW_TASK = 0x10000000
So, the combination results in 0x30000000
Also, as mentioned in docs the new task flag i.e,FLAG_ACTIVITY_NEW_TASK
is used to achieve the following behaviour:
When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in.
and the single top flag i.e, FLAG_ACTIVITY_SINGLE_TOP
is used to achieve the following behaviour, as mentioned in the docs :
If set, the activity will not be launched if it is already running at the top of the history stack.
So, these flags help to resume your activity and prevents from opening a new activity.
Upvotes: 7