[Java] 纯文本查看 复制代码 public class ThreadUtils {
/**
* 获得当前进程的名字
*
* @param context
* [url=home.php?mod=space&uid=3039]@return[/url] 进程号
*/
public static String getCurProcessName(Context context) {
int pid = android.os.Process.myPid();
ActivityManager activityManager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
.getRunningAppProcesses()) {
if (appProcess.pid == pid) {
return appProcess.processName;
}
}
return null;
}
}
|