Java tutorial
//package com.java2s; //License from project: Apache License import android.app.ActivityManager; import android.content.Context; public class Main { public static String getCurrentProcessName(Context pContext) { int pid = android.os.Process.myPid(); ActivityManager mActivityManager = (ActivityManager) pContext.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return appProcess.processName; } } return ""; } }