gpt4 book ai didi

java - 获取特定应用程序的所有服务列表(来自 list )

转载 作者:行者123 更新时间:2023-12-01 23:18:24 24 4
gpt4 key购买 nike

如何从特定应用获取 AndroidManifest.xml 中声明的所有服务的列表?

换句话说,我编写了一个带有包“com.example.exampleapp”的应用程序。如何获取 list 文件中先前声明的所有权限的列表?

最佳答案

这可能对你有帮助...

    int flags = PackageManager.GET_ACTIVITIES
| PackageManager.GET_CONFIGURATIONS
| PackageManager.GET_DISABLED_COMPONENTS
| PackageManager.GET_GIDS | PackageManager.GET_INSTRUMENTATION
| PackageManager.GET_INTENT_FILTERS
| PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS
| PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES
| PackageManager.GET_SIGNATURES;
PackageManager packageManager = getPackageManager();
List<PackageInfo> installedPackages = packageManager
.getInstalledPackages(flags);
for (PackageInfo packageInfo : installedPackages) {
ServiceInfo[] services = packageInfo.services;
PermissionInfo[] permissions = packageInfo.permissions;
}

对于特定的包...

    StringBuffer buffer = new StringBuffer();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(
"packageName", flags);
ServiceInfo[] services = packageInfo.services;
for (ServiceInfo serviceInfo : services) {
buffer.append(serviceInfo.name + "\n");
}
PermissionInfo[] permissions = packageInfo.permissions;
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textView.setText(buffer);

关于java - 获取特定应用程序的所有服务列表(来自 list ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20881618/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com