1.理解
uid:uid 对于 应用来说其实就是指我们当前应用是在那个 group 组内
就是指这个shareuserid,一个组内的uid相同,,并且具有相同的uid的应用才能共享用户内存
pid:是指每个进程在liunx下的 进程的id 是唯一的。
2.获取
获取uid:
PackageManager pm = getPackageManager();ApplicationInfo ai = pm.getApplicationInfo("com.speedsoftware.rootexplorer", PackageManager.GET_ACTIVITIES);
Log.d("!!", "!!" + ai.uid);
获取pid:
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); List list = activityManager.getRunningAppProcesses();
for(ActivityManager.RunningAppProcessInfo runningAppProcessInfo : list){
if(runningAppProcessInfo.pid == pid){
processName = runningAppProcessInfo.processName;
}
}