Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> getAppPermission(Context mContext, String packageName) {
        List<String> mList = new ArrayList<>();
        try {
            PackageManager pm = mContext.getPackageManager();
            PackageInfo pack = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
            String[] permissionStrings = pack.requestedPermissions;
            if (permissionStrings != null) {
                for (int i = 0; i < permissionStrings.length; i++) {
                    mList.add(permissionStrings[i]);
                }
            }
            return mList;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return mList;
    }
}