Skip to content

Instantly share code, notes, and snippets.

@bitristan
Created September 7, 2015 08:42
Show Gist options
  • Save bitristan/2ecead050b2154ad6b10 to your computer and use it in GitHub Desktop.
Save bitristan/2ecead050b2154ad6b10 to your computer and use it in GitHub Desktop.
Get current process name.
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