获得手机的全部权限
1 private void per() { 2 StringBuffer appNameAndPermissions = new StringBuffer(); 3 PackageManager pm = getPackageManager(); 4 List<ApplicationInfo> packages = pm 5 .getInstalledApplications(PackageManager.GET_META_DATA); 6 for (ApplicationInfo applicationInfo : packages) { 7 try { 8 PackageInfo packageInfo = pm.getPackageInfo( 9 applicationInfo.packageName, 10 PackageManager.GET_PERMISSIONS); 11 appNameAndPermissions.append(packageInfo.packageName + "*:\n"); 12 // Get Permissions 13 String[] requestedPermissions = packageInfo.requestedPermissions; 14 if (requestedPermissions != null && requestedPermissions.toString().contains("haodf")) { 15 for (int i = 0; i < requestedPermissions.length; i++) { 16 Log.d("test", requestedPermissions[i]); 17 appNameAndPermissions.append(requestedPermissions[i] 18 + "\n"); 19 } 20 appNameAndPermissions.append("\n"); 21 } 22 } catch (NameNotFoundException e) { 23 e.printStackTrace(); 24 } 25 } 26 }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。