Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.ActivityManager; import android.app.ActivityManager.RunningAppProcessInfo; import android.content.Context; import android.text.TextUtils; import java.util.List; public class Main { public static boolean isNamedProcess(Context context, String processName) { if (context == null || TextUtils.isEmpty(processName)) { return false; } int pid = android.os.Process.myPid(); ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> processInfoList = manager.getRunningAppProcesses(); if (processInfoList == null) { return true; } for (RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { if (processInfo.pid == pid && processName.equalsIgnoreCase(processInfo.processName)) { return true; } } return false; } }