Created
September 18, 2014 03:12
-
-
Save dcaoyuan/199c098c7acd9e9a1639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isApplicationBroughtToBackground() { | |
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
List<RunningTaskInfo> tasks = am.getRunningTasks(1); | |
if (!tasks.isEmpty()) { | |
ComponentName topActivity = tasks.get(0).topActivity; | |
if (!topActivity.getPackageName().equals(context.getPackageName())) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment