Android examples for Android OS:Process
get Current Process Name
import android.app.ActivityManager; import android.app.Application; import android.content.Context; public class Main { private static Application sApp; public static String getCurrentProcessName() { int pid = android.os.Process.myPid(); ActivityManager activityManager = (ActivityManager) sApp.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return appProcess.processName; }//from ww w. j a v a 2 s.c o m } return null; } }