我们可以在Image
中定义为活动或服务的android:process
,称为子流程。
例如,我的包名称为AndroidManifest.xml
,并且定义了两个子流程:
'com.test.main'
我的问题是:
将apk文件安装到android设备后,如何通过adb或其他已安装的应用程序获取所有这些子进程列表信息,例如android:process=":tool"
android:process=":bar"
,com.test.main:tool
?
答案 0 :(得分:0)
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();
}