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


Java PackageManager.getPermissionInfo方法代码示例

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


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

示例1: getPermissionInfo

import android.content.pm.PackageManager; //导入方法依赖的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: getPermissions

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * use for get {@link PermissionInfo} of all @param required
 *
 * @param context
 * @param required
 * @return
 */
private static List<PermissionInfo> getPermissions(Context context, List<String> required) {

    List<PermissionInfo> permissionInfoList = new ArrayList<>();

    PackageManager pm = context.getPackageManager();
    for (String permission : required) {
        PermissionInfo pinfo = null;
        try {
            pinfo = pm.getPermissionInfo(permission, PackageManager.GET_META_DATA);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            continue;
        }

        permissionInfoList.add(pinfo);
    }
    return permissionInfoList;
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:26,代码来源:PermissionsHelper.java

示例3: getPermissionInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private PermissionInfo getPermissionInfo(PackageManager packageManager, String permission) {
    if (TextUtils.isEmpty(permission)) {
        return null;
    }
    try {
        return packageManager.getPermissionInfo(permission, 0);
    } catch (PackageManager.NameNotFoundException e) {
        UILog.w("Can't find permission " + permission, e);
        return null;
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:12,代码来源:OpsItemAdapter.java

示例4: getPermissionDetails

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public PermissionDetails getPermissionDetails(Context context, String permission, int permissionDrawableResID) {
    PackageManager pm = context.getPackageManager();
    PermissionInfo info = null;
    try {
        info = pm.getPermissionInfo(permission, PackageManager.GET_META_DATA);
        String text = info.loadDescription(context.getPackageManager()).toString();
        this.permission = permission;
        this.description = text;
        this.protectionLevel = info.protectionLevel;
        this.drawableResId = permissionDrawableResID;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return this;
}
 
开发者ID:KingsMentor,项目名称:Rationale,代码行数:16,代码来源:PermissionDetails.java


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