想通过编程实现用Android开发获取一个APK的权限。
发布网友
发布时间:2024-09-29 23:41
我来回答
共2个回答
热心网友
时间:2024-12-01 22:20
StringBuffer appNameAndPermissions=new StringBuffer();
PackageManager pm = getPackageManager();
List packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : packages) {
Log.d("test", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);
try {
PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);
appNameAndPermissions.append(packageInfo.packageName+"*:\n");
//Get Permissions
String[] requestedPermissions = packageInfo.requestedPermissions;
if(requestedPermissions != null) {
for (int i = 0; i < requestedPermissions.length; i++) {
Log.d("test", requestedPermissions[i]);
appNameAndPermissions.append(requestedPermissions[i]+"\n");
}
appNameAndPermissions.append("\n");
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}}
热心网友
时间:2024-12-01 22:20
你思路不是很清晰吗?
还想问什么?追问我不会啊,求程序。