We can define android:process
for activity or service in AndroidManifest.xml
named as sub-process. for example, my package name is 'com.test.main'
and I defined two sub-processes:
android:process=":tool"
android:process=":bar"
My question is:
After install apk file into a android device, how can we get all these subprocess list info, for example com.test.main:tool
, com.test.main:bar
, through adb or another installed app?
String pkg = "com.google.android.gms";
try {
// Ref: https://developer.android.com/guide/components/processes-and-threads
PackageInfo packageInfo = getPackageManager().getPackageInfo(pkg, PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS);
List<ComponentInfo> list = new ArrayList<>();
if (packageInfo.activities != null) Collections.addAll(list, packageInfo.activities);
if (packageInfo.services != null) Collections.addAll(list, packageInfo.services);
if (packageInfo.receivers != null) Collections.addAll(list, packageInfo.receivers);
if (packageInfo.providers != null) Collections.addAll(list, packageInfo.providers);
for (ComponentInfo componentInfo : list) {
Utils.log("componentInfo: " + componentInfo.processName);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.