Skip to content

Instantly share code, notes, and snippets.

@mattbriancon
Created February 9, 2012 16:32
Show Gist options
  • Save mattbriancon/1780940 to your computer and use it in GitHub Desktop.
Save mattbriancon/1780940 to your computer and use it in GitHub Desktop.
Find running Activities
ActivityManager mgr = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = mgr.getRunningTasks(100);
int num = 0;
for(ActivityManager.RunningTaskInfo i : tasks) {
String ACT = "com.your.package/com.your.package.MainActivity";
if(i.topActivity.flattenToString().equals(ACT))
num = i.numActivities;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment