Created
May 23, 2016 06:33
-
-
Save BCsl/aa3711cc51a99bd6be1a0704a3aceaa5 to your computer and use it in GitHub Desktop.
MultiProcess
This file contains hidden or 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
| /** | |
| * 获取当前进程名 | |
| * @param context | |
| * @return | |
| */ | |
| public static String getCurrProcessName(Context context) { | |
| try { | |
| final int currProcessId = android.os.Process.myPid(); | |
| final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
| List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses(); | |
| if (processInfos != null) { | |
| for (ActivityManager.RunningAppProcessInfo info : processInfos) { | |
| if (info.pid == currProcessId) { | |
| return info.processName; | |
| } | |
| } | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment