Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:25:47+00:00 2026-06-14T19:25:47+00:00

Im trying to list the protection level for each permission in the selected application,

  • 0

Im trying to list the protection level for each permission in the selected application, for the code given below. But i do not know how to get it done.

ArrayList<String> list_permission = new ArrayList<String>();
        String[] reqp = info.requestedPermissions;
        if (reqp != null) {
            for (i = 0; i < reqp.length; i++) {

                k = i + 1;

                String a = reqp[i];
                if (a.contains("android.permission.")) {
                    String aa[] = a.split("android.permission.");
                    list_permission.add(aa[1]);
                } else {
                    list_permission.add(a);
                }

            }

        }

can anyone help me with this… just want to add the protection level in front of the permission.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:25:48+00:00Added an answer on June 14, 2026 at 7:25 pm

    You can use PackageManager class getPermissionInfo() method to get PermissionInfo object for any particular permission. PermissionInfo object has property Protection Lavel that can be used to check the protection level of any permission… You can check it against the constant defined in the PermissoinInfo class like PROTECTION_FLAG_SYSTEM.

    Like following code :

    for (PermissionInfo permission : packageInfo.permissions) {
        // Dump permission info
        String protectionLevel;
        switch(permission.protectionLevel) {
        case PermissionInfo.PROTECTION_NORMAL : protectionLevel = "normal"; break;
        case PermissionInfo.PROTECTION_DANGEROUS : protectionLevel = "dangerous"; break;
        case PermissionInfo.PROTECTION_SIGNATURE : protectionLevel = "signature"; break;
        case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM : protectionLevel = "signatureOrSystem"; break;
        default : protectionLevel = "<unknown>"; break;
        }
        Log.i("PermissionCheck", permission.name + " " + protectionLevel);
      }
    

    UPDATE:

    To get the Protection level of requestedPermissions:

    String[] reqp = info.requestedPermissions;
    String perm = reqp[i];
    if (perm.contains("android.permission.")) {
        try {
            PermissionInfo pi = getPackageManager().getPermissionInfo(perm, PackageManager.GET_META_DATA);
            String protctionLevel = "unknown";
    
            switch(pi.protectionLevel) {
                case PermissionInfo.PROTECTION_NORMAL : protctionLevel = "normal"; break;
                case PermissionInfo.PROTECTION_DANGEROUS : protctionLevel = "dangerous"; break;
                case PermissionInfo.PROTECTION_SIGNATURE : protctionLevel = "signature"; break;
                case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM : protctionLevel = "signatureOrSystem"; break;
                case PermissionInfo.PROTECTION_FLAG_SYSTEM : protctionLevel = "system"; break;
                default : protctionLevel = "<unknown>"; break;
            }
            list_permission.add(perm + "        "+protctionLevel);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
    } else {
        list_permission.add(perm);
    }
    

    Following line would only work on API level 16 or above:

            case PermissionInfo.PROTECTION_FLAG_SYSTEM : protctionLevel = "system"; break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get my contacts on a list view. Now I know that
I am trying to get all contacts in the favourites list of the Android
I am trying to get top I/O performance in a data streaming application with
I am trying to trim a projection property but it does not let me
So i'm trying to understand all the code from the NotePad sample, but i'm
I'm trying to list the system default bookmarks but when I run the app,
I'm trying to get a list of unread email from K-9 email client. I'm
Im trying to list all categories in a VPP-folder using a module from Meridium
I'm trying to list a few date ranges based off the last Tuesday which
I am trying to list files in subdirectories and write these lists into separate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.