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?
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?
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.