获取进程

private String getProcessName(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

    List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();

    if (runningApps == null) {

        return null;

    }

    for (ActivityManager.RunningAppProcessInfo proInfo : runningApps) {

        if (proInfo.pid == android.os.Process.myPid()) {

            if (proInfo.processName != null) {

                return proInfo.processName;

            }

        }

    }

    return null;
}
    原文作者:奔跑的图腾
    原文地址: https://www.jianshu.com/p/210664d8290e
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞