Skip to content

Instantly share code, notes, and snippets.

@voltazor
Created February 7, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voltazor/c0c91ef7aa5a6fa8179d to your computer and use it in GitHub Desktop.
Save voltazor/c0c91ef7aa5a6fa8179d to your computer and use it in GitHub Desktop.
Check Android application backgroung/foreground/visible
public static final int IMPORTANCE_BACKGROUND = 400;
public static final int IMPORTANCE_FOREGROUND = 100;
public static final int IMPORTANCE_VISIBLE = 200;
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> list2 = am.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo ti : list2) {
Log.i("IMPORTANCE CODE", String.valueOf(ti.importance));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment