3

By using activityManager.getRunningTasks you can get the current running applications in android.
How ever it does not tell you which of those tasks activity is showing right now.

How do I get this information?

1 Answer 1

1

To get topmost activity you will need to interrogate the first task returned by getRunningTasks:

ActivityManager activityManager = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
RunningTaskInfo info = activityManager.getRunningTasks(1).get(0);
ComponentName topActivity = info.topActivity.getClassName();


BTW, the word is that getRunningTasks will be deprecated in Android L, so keep in mind.


Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.