private static List < String > getManifestPermissions ( Context context ) { try { PackageInfo packageInfo = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , PackageManager . GET_PERMISSIONS ) ; String [ ] permissions = packageInfo . requestedPermissions ; if ( permissions == null || permissions . length == 0 ) { throw new IllegalStateException ( "You did not register any permissions in the manifest.xml." ) ; } return Collections . unmodifiableList ( Arrays . asList ( permissions ) ) ; } catch ( PackageManager . NameNotFoundException e ) { throw new AssertionError ( "Package name cannot be found." ) ; } }
Get a list of permissions in the manifest .