2

I am trying to launch last recent task from task list in android . Using ActivityManager to get list of tasks. This will get me task id,baseintent etc ActivityManager m = (ActivityManager)ChatHeadService.this.getSystemService(ACTIVITY_SERVICE); List recentTasks = m.getRecentTasks(2, ActivityManager.RECENT_WITH_EXCLUDED);

this is the code i am using to get last .

but when i run this its not switching .

if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                        final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
                        am.moveTaskToFront(apps.id, ActivityManager.MOVE_TASK_WITH_HOME);
                    } else { // API 10 and below (Gingerbread on down)
                        Intent restartTaskIntent = new Intent(apps.baseIntent);
                        if (restartTaskIntent != null) {
                            restartTaskIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
                            try {
                                startActivity(restartTaskIntent);
                            } catch (ActivityNotFoundException e) {
                                Log.w("MyApp", "Unable to launch recent task", e);
                            }
                        }
                    }

This is also not working for me.

I am looking for apps like this

bpbhat77
  • 529
  • 1
  • 6
  • 19

0 Answers0