Programmatically retrieve permissions from manifest.xml in android

前端 未结 5 721
无人共我
无人共我 2020-12-05 18:39

I have to programmatically retrieve permissions from the manifest.xml of an android application and I don\'t know how to do it.

I read the post here but I am not ent

5条回答
  •  臣服心动
    2020-12-05 19:01

    You can used this function:

    public boolean hasPermission(Context ctx,String permission){
            return ctx.getPackageManager().checkPermission(permission, ctx.getPackageName())
                   == PackageManager.PERMISSION_GRANTED); 
    }
    

    Usage:

    hasPermission(this,Manifest.permission.GET_ACCOUNTS);
    

提交回复
热议问题