Created
September 7, 2015 08:42
-
-
Save bitristan/2ecead050b2154ad6b10 to your computer and use it in GitHub Desktop.
Get current process name.
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 String getCurrentProcessName() { | |
String processName = ""; | |
int pid = android.os.Process.myPid(); | |
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); | |
for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { | |
if (processInfo.pid == pid) { | |
processName = processInfo.processName; | |
break; | |
} | |
} | |
return processName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment