Launching an activity at its current state.
Posted
by Profete162
on Stack Overflow
See other posts from Stack Overflow
or by Profete162
Published on 2010-05-17T21:50:17Z
Indexed on
2010/05/18
4:00 UTC
Read the original article
Hit count: 259
Hello,
I am trying to make a task switcher and i succed in it. My only problem is that when I launch activities, they are relaunched as they were new activities ( for instance, I am writing an email, i press home and go into my activity,launch email, and then the app launch the email bout goes back at the inbox and the email is lost) So that's not true multitasking.
Here are my steps:
1) getting all the running apps:
List<ActivityManager.RunningTaskInfo> allTasks = activityManager.getRunningTasks(30);
2) getting the intent:
for (ActivityManager.RunningTaskInfo aTask : allTasks) {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(aTask.baseActivity);
(...)
3) Launching the application when clicking on the button:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED).addCategory(Intent.CATEGORY_LAUNCHER);
monthis.startActivity(intent);
`
What is wrong with this code? Should I do something different to get it?
Thank a lot for any answer.
© Stack Overflow or respective owner