当前位置: 首页>>代码示例>>Java>>正文


Java PermissionInfo.loadLabel方法代码示例

本文整理汇总了Java中android.content.pm.PermissionInfo.loadLabel方法的典型用法代码示例。如果您正苦于以下问题:Java PermissionInfo.loadLabel方法的具体用法?Java PermissionInfo.loadLabel怎么用?Java PermissionInfo.loadLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PermissionInfo的用法示例。


在下文中一共展示了PermissionInfo.loadLabel方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPermissionInfo

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
/**
 * Returns information string about permission
 **/
@Nullable
private static String getPermissionInfo(@NonNull Context context, @NonNull String permission) {
    context = context.getApplicationContext();
    PackageManager pm = context.getPackageManager();
    PermissionInfo info = null;
    try {
        info = pm.getPermissionInfo(permission, PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException ex) {
        Log.w(TAG, ex);
    }

    if (info != null) {
        CharSequence label = info.loadLabel(pm);
        if (label == null) {
            label = info.nonLocalizedLabel;
        }
        return label.toString();
    }

    return null;
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:25,代码来源:Permissions.java

示例2: doPermissionCheck

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
private void doPermissionCheck(Context context, ResultCollector collector, final String permission) {
    PackageManager pm = context.getPackageManager();
    try {
        PermissionInfo info = pm.getPermissionInfo(permission, 0);
        PermissionGroupInfo groupInfo = info.group != null ? pm.getPermissionGroupInfo(info.group, 0) : null;
        CharSequence permLabel = info.loadLabel(pm);
        CharSequence groupLabel = groupInfo != null ? groupInfo.loadLabel(pm) : permLabel;
        collector.addResult(context.getString(R.string.self_check_name_permission, permLabel),
                context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED ? Positive : Negative,
                context.getString(R.string.self_check_resolution_permission, groupLabel),
                new SelfCheckGroup.CheckResolver() {

                    @Override
                    public void tryResolve(Fragment fragment) {
                        fragment.requestPermissions(new String[]{permission}, 0);
                    }
                });
    } catch (PackageManager.NameNotFoundException e) {
        Log.w(TAG, e);
    }
}
 
开发者ID:microg,项目名称:android_external_MicroGUiTools,代码行数:22,代码来源:PermissionCheckGroup.java

示例3: getHumanReadablePermissionString

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
private static String getHumanReadablePermissionString(String paramString)
{
  try
  {
    PermissionInfo localPermissionInfo = FinskyApp.get().getPackageManager().getPermissionInfo(paramString, 0);
    if (localPermissionInfo != null)
    {
      CharSequence localCharSequence = localPermissionInfo.loadLabel(FinskyApp.get().getPackageManager());
      if (localCharSequence == null) {
        return null;
      }
      String str = localCharSequence.toString();
      return str;
    }
  }
  catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
  return null;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:19,代码来源:PermissionsBucketer.java

示例4: getPermissionLabel

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
private static String getPermissionLabel(Context context, String permission, String defValue)
{
	try
	{
		final PackageManager pm = context.getPackageManager();
		final PermissionInfo pi = pm.getPermissionInfo(permission, 0);

		final CharSequence label = pi.loadLabel(pm);
		if(label != null && !label.toString().equals(permission))
			return label.toString();
	}
	catch(NameNotFoundException e)
	{
		// om nom nom
	}

	return defValue;
}
 
开发者ID:jclehner,项目名称:AppOpsXposed,代码行数:19,代码来源:OpsLabelHelper.java

示例5: map

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
@Override public Permission map(PermissionInfo permissionInfo) {
  CharSequence name = permissionInfo.loadLabel(packageManager);
  CharSequence description = permissionInfo.loadDescription(packageManager);

  return Permission.builder()
      .id(permissionInfo.name)
      .title(name != null ? name.toString() : "")
      .description(description != null ? description.toString() : "")
      .permissionGroup(permissionInfo.group)
      .protectionLevel(permissionInfo.protectionLevel)
      .build();
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:13,代码来源:ToPermissionMapper.java

示例6: getPermissionNames

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
/**
 * use for get name of permission for all @param required
 *
 * @param context
 * @param required
 * @return
 */
private static String[] getPermissionNames(Context context, List<String> required) {
    PackageManager pm = context.getPackageManager();
    String[] names = new String[required.size()];
    int i = 0;
    for (PermissionInfo permissionInfo : getPermissions(context, required)) {
        CharSequence label = permissionInfo.loadLabel(pm);
        names[i] = label.toString();
        i++;
    }
    return names;
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:19,代码来源:PermissionsHelper.java

示例7: parsePermissions

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
public static List<ApkPermission> parsePermissions(Context context, List<String> permissionArray) {
    List<ApkPermission> list = new ArrayList<>();
    CharSequence csPermissionGroupLabel;
    CharSequence csPermissionLabel;
    PackageManager pm = context.getPackageManager();

    List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(PackageManager.PERMISSION_GRANTED);
    for (String permission : permissionArray) {

        for (PermissionGroupInfo pgi : lstGroups) {
            try {
                List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, PackageManager.PERMISSION_GRANTED);
                for (PermissionInfo pi : lstPermissions) {
                    if (pi.name.equals(permission)) {
                        csPermissionLabel = pi.loadLabel(pm);
                        csPermissionGroupLabel = pgi.loadLabel(pm);
                        list.add(new ApkPermission(csPermissionGroupLabel.toString(), csPermissionLabel.toString()));
                    }
                }
            } catch (Exception e) {
                Logger.printException(e);
            }
        }
    }

    Collections.sort(list, new Comparator<ApkPermission>() {
        @Override
        public int compare(ApkPermission lhs, ApkPermission rhs) {
            return lhs.getName().compareTo(rhs.getName());
        }
    });

    return list;
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:35,代码来源:AptoideUtils.java

示例8: permissions

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
public static ArrayList<ApkPermission> permissions(Context context, ArrayList<String> permissionArray) {
    PackageManager pm = context.getPackageManager();

    CharSequence csPermissionGroupLabel;
    CharSequence csPermissionLabel;
    List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(0);
    ArrayList<ApkPermission> list = new ArrayList<>();

    if (permissionArray != null) {
        for (int i = 0; i != permissionArray.size(); i++) {
            String permission = permissionArray.get(i);

            for (PermissionGroupInfo pgi : lstGroups) {
                try {
                    List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, 0);
                    for (PermissionInfo pi : lstPermissions) {
                        if (pi.name.equals(permission)) {
                            csPermissionLabel = pi.loadLabel(pm);
                            csPermissionGroupLabel = pgi.loadLabel(pm);
                            list.add(new ApkPermission(csPermissionGroupLabel.toString(), csPermissionLabel.toString()));
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
        Collections.sort(list, new Comparator<ApkPermission>() {
            @Override
            public int compare(ApkPermission lhs, ApkPermission rhs) {
                return lhs.getName().compareTo(rhs.getName());
            }
        });
    }

    return list;
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:38,代码来源:PermissionsActivity.java

示例9: getApkPermissions

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
public ArrayList<ApkPermission> getApkPermissions() throws JSONException {

        JSONArray permissionArray = response.getJSONArray("permissions");
        PackageManager pm = BackupAppsApplication.getContext().getPackageManager();

        CharSequence csPermissionGroupLabel;
        CharSequence csPermissionLabel;
        List<PermissionGroupInfo> lstGroups = pm.getAllPermissionGroups(0);


        ArrayList<ApkPermission> list = new ArrayList<ApkPermission>();
        for(int i = 0; i!= permissionArray.length(); i++){
            String permission = permissionArray.getString(i);

            for (PermissionGroupInfo pgi : lstGroups) {
                csPermissionGroupLabel = pgi.loadLabel(pm);
                //Log.e("perm", pgi.name + ": " + csPermissionGroupLabel.toString());

                try {
                    List<PermissionInfo> lstPermissions = pm.queryPermissionsByGroup(pgi.name, 0);
                    for (PermissionInfo pi : lstPermissions) {
                        csPermissionLabel = pi.loadLabel(pm);

                        if(pi.name.equals(permission))
                            list.add(new ApkPermission(csPermissionGroupLabel.toString(), csPermissionLabel.toString()));
                            //Log.e("perm", "   " + pi.name + ": " + csPermissionLabel.toString());
                        }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }

        return list;

    }
 
开发者ID:Aptoide,项目名称:aptoide-backup-apps,代码行数:37,代码来源:WebserviceGetApkInfo.java

示例10: parsePermissions

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
public static List<ApkPermission> parsePermissions(Context context,
    List<String> permissionArray) {
  List<ApkPermission> list = new ArrayList<>();
  CharSequence csPermissionGroupLabel;
  CharSequence csPermissionLabel;
  PackageManager pm = context.getPackageManager();

  List<PermissionGroupInfo> lstGroups =
      pm.getAllPermissionGroups(PackageManager.PERMISSION_GRANTED);
  for (String permission : permissionArray) {

    for (PermissionGroupInfo pgi : lstGroups) {
      try {
        List<PermissionInfo> lstPermissions =
            pm.queryPermissionsByGroup(pgi.name, PackageManager.PERMISSION_GRANTED);
        for (PermissionInfo pi : lstPermissions) {
          if (pi.name.equals(permission)) {
            csPermissionLabel = pi.loadLabel(pm);
            csPermissionGroupLabel = pgi.loadLabel(pm);
            list.add(new ApkPermission(csPermissionGroupLabel.toString(),
                csPermissionLabel.toString()));
          }
        }
      } catch (Exception e) {
        Logger.e(TAG, e);
        throw new RuntimeException(e);
      }
    }
  }

  Collections.sort(list, (lhs, rhs) -> lhs.getName()
      .compareTo(rhs.getName()));

  return list;
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:36,代码来源:AptoideUtils.java

示例11: afterOnCreateView

import android.content.pm.PermissionInfo; //导入方法依赖的package包/类
@Override
    protected void afterOnCreateView(View view) {
        super.afterOnCreateView(view);
        mGroupTextView = (TextView) view.findViewById(R.id.group);
        mDescribeTextView = (TextView) view.findViewById(R.id.describe);
        mLabelTextView = (TextView) view.findViewById(R.id.label);
        mValueTextView = (TextView) view.findViewById(R.id.value);
        PermissionInfo info = null;
        CharSequence describe = null;
        CharSequence label = null;
        try {
            info = getActivity().getPackageManager().getPermissionInfo(mPermissionName, PackageManager.GET_META_DATA);
//            info.describeContents();
            label = info.loadLabel(getActivity().getPackageManager());
            describe = info.loadDescription(getActivity().getPackageManager());
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        mValueTextView.setText(info.name);
        mLabelTextView.setText(label);
        if(info.group != null && !info.group.equals("")){
            mGroupTextView.setText(info.group);
            final PermissionInfo finalInfo = info;
            mGroupTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PermissionGroupDetailFragment fragment = PermissionGroupDetailFragment.newInstance(finalInfo.group);
                    showFragment(fragment);
                }
            });
        }
        mDescribeTextView.setText(describe);

        getUIKits().getToolBar().getToolbar().setTitle("权限详情信息");
    }
 
开发者ID:binkery,项目名称:allinone,代码行数:36,代码来源:PermissionDetailFragment.java


注:本文中的android.content.pm.PermissionInfo.loadLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。