Whenever we start any Activity, we get information about the uid, gid, etc, something like this:
I/ActivityManager( 1986): Start proc app.processName for activity hostingNameStr: pid=3641 uid=10109 gids={3003, 1007}
Now using PackageManager, we can get the packageName, uid and pid something like this:
List<ApplicationInfo> packages = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d("ME", "packageInfo is :" + packageInfo);
Log.d("ME", "Installed package :" + packageInfo.packageName);
Log.d("ME", "Package process for " + packageInfo.packageName+"-->" + packageInfo.processName);
Log.d("ME", "Package uid for " + packageInfo.packageName+"-->"+packageInfo.uid);
}
But here, I’m not able to get the gid and so was wondering whether getting gid like this is even possible or not.
Try to have a look at the methods that are provided by
Processclass. For instance, in your casegetGidForName(String name). It returns int values, GID, but I do not know how to select the list of all gids.EDIT:
I was a bit confused with applicationInfo. You can use PackageManager’s method getPackageGids(String packageName) or you can get all PackageInfo and then read value of the
gidsfield.