How to get App's Permission for each app? how to do it programmatically on Android?

后端 未结 4 1288
花落未央
花落未央 2020-11-27 08:03

How to get App\'s Permission Detail for each app? how to do it programmatically?

I want to display \"App\'s Permission Detail for each app\" on Text

相关标签:
4条回答
  • 2020-11-27 08:03

    Use the following code in your activity:

    I created StringBuffer appNameAndPermissions = new StringBuffer(); to append all the apps and permisssions info.

    It's working fine. I tested it already. If you have any issues, please let me know.

    StringBuffer appNameAndPermissions = new StringBuffer();
    PackageManager pm = getPackageManager();
    List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
    
    for (ApplicationInfo applicationInfo : packages) {
        Log.d("test", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);
    try {
        PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);
        appNameAndPermissions.append(packageInfo.packageName+"*******:\n");
    
        //Get Permissions
        String[] requestedPermissions = packageInfo.requestedPermissions;
        if(requestedPermissions != null) {
            for (int i = 0; i < requestedPermissions.length; i++) {
                Log.d("test", requestedPermissions[i]);
                appNameAndPermissions.append(requestedPermissions[i]+"\n");
            }
        appNameAndPermissions.append("\n");
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    

    Use the following permission in your AndroidManifest.xml file:

    <uses-permission android:name="android.permission.GET_TASKS"/>

    0 讨论(0)
  • 2020-11-27 08:11

    Zhocker

    To uninstall any app use below code

    Intent i = new Intent(Intent.ACTION_DELETE);
    i.setData(Uri.parse("package:com.package name"));
    startActivity(i); 
    

    And to get permissions use getInstalledPackages(int) with the flag GET_PERMISSIONS

    0 讨论(0)
  • 2020-11-27 08:14

    You need to use PackageManager's GET_PERMISSIONS flag.

    Check this question.

    0 讨论(0)
  • 2020-11-27 08:27
    1. For App's permission go to Manifest file ans see.

    2.for uninstall the app follow the below points:-

    a. go to setting b. then Open Application c. then open Manage Application d. then choose the app which you want to Uninstall e. then click on Uninstall and Uninstall the app.

    0 讨论(0)
提交回复
热议问题