String processName = OsUtils.getProcessName(this, android.os.Process.myPid()); if (processName != null) { boolean defaultProcess = processName.equals(Constants.REAL_PACKAGE_NAME); if (defaultProcess) { initAppForMainProcess(); } else if (processName.contains(":webbrowser")) { initAppForWebBrowseProcess(); } else if (processName.contains(":wallet")) { } }
/** * @return null may be returned if the specified process not found */ public static String getProcessName(Context cxt, int pid) { ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> runningApps = am.getRunningAppProcesses(); if (runningApps == null) { return null; } for (RunningAppProcessInfo procInfo : runningApps) { if (procInfo.pid == pid) { return procInfo.processName; } } return null; }