码迷,mamicode.com
首页 > 移动开发 > 详细

获得手机的全部权限

时间:2014-09-18 18:27:14      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   for   div   sp   log   

 

 

 

 

 

 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     }

 

获得手机的全部权限

标签:style   blog   color   io   os   for   div   sp   log   

原文地址:http://www.cnblogs.com/flyingsir/p/3979604.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!