Android: Get app-owned permissions

Source: Internet
Author: User

Log output permissions that an app has
PackageManager pm = context.getPackageManager();PackageInfo pi;try {    // 参数2必须是PackageManager.GET_PERMISSIONS    pi = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);    String[] permissions = pi.requestedPermissions;    ifnull){        for(String str : permissions){            Log.i(TAG, str);        }    catch (NameNotFoundException e) {    e.printStackTrace();}

In the code above, PackageName is the package name of the target app.

Returns the permission information for an app with the list collection

Based on the above code, modify the following method:

new ArrayList<PermissionInfo>();PackageManager pm = context.getPackageManager();PackageInfo pi;try {    pi = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);    String[] permissions = pi.requestedPermissions;    ifnull){        for(String str : permissions){            0);            permissionInfoList.add(permissionInfo);        }    catch (NameNotFoundException e) {    e.printStackTrace();}return permissionInfoList;

Based on the code above, you get richer permission information.

Specific information can be found in the page getAppPermissionList and showAppPermissionList methods.

Android: Get app-owned permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.