當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。