Created
March 27, 2016 20:54
-
-
Save RaghavSood/ac835e8baf937670b20f 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
public String getForegroundPackage() { | |
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); | |
RunningTaskInfo foregroundTaskInfo; | |
foregroundTaskInfo = am.getRunningTasks(1).get(0); | |
String foregroundTaskPackageName = foregroundTaskInfo.topActivity.getPackageName(); | |
return foregroundTaskPackageName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment