I am trying to make a task switcher and I succeeded 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 to 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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…