Finding permission Group Name from permission Name Android -
i need find permission group name contacts,storage etc permission name. have following code
public arraylist<string> permissiongroup(arraylist<string> permission) { arraylist<string>grouppermission = new arraylist<>(); packagemanager pm = getpackagemanager(); for(string entry : permission){ permissiongroupinfo info = null; try { info =pm.getpermissiongroupinfo(entry,0); } catch (packagemanager.namenotfoundexception e) { log.w("infoerror ", e.getstacktrace().tostring()); } if(info == null){ log.w("infonull","error"); } else { string loadlabelval = info.loadlabel(pm).tostring(); log.w("groupname ", loadlabelval); if (!grouppermission.contains(loadlabelval)) { grouppermission.add(loadlabelval); } } } return grouppermission; }
here input te function arraylist of permissions corresponding group needs found. getting pm.getpermissiongroupinfo(entry,0) null. dont know mistake. pls correct me.
thanks in advance.
to "short name" example "location" can use
packagemanager packagemanager = getapplicationcontext().getpackagemanager(); permissioninfo permissioninfo = packagemanager.getpermissioninfo(manifest.permission.access_fine_location, 0); permissiongroupinfo permissiongroupinfo = packagemanager.getpermissiongroupinfo(permissioninfo.group, 0); log.w("11_app", ""+permissiongroupinfo.loadlabel(packagemanager));
Comments
Post a Comment