PackageManager.AddPermission(PermissionInfo) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Add a new dynamic permission to the system.
[Android.Runtime.Register("addPermission", "(Landroid/content/pm/PermissionInfo;)Z", "GetAddPermission_Landroid_content_pm_PermissionInfo_Handler")]
public abstract bool AddPermission (Android.Content.PM.PermissionInfo info);
[<Android.Runtime.Register("addPermission", "(Landroid/content/pm/PermissionInfo;)Z", "GetAddPermission_Landroid_content_pm_PermissionInfo_Handler")>]
abstract member AddPermission : Android.Content.PM.PermissionInfo -> bool
Parameters
- info
- PermissionInfo
Description of the permission to be added.
Returns
Returns true if a new permission was created, false if an existing one was updated.
- Attributes
Exceptions
if you are not allowed to add the given permission name.
Remarks
Add a new dynamic permission to the system. For this to work, your package must have defined a permission tree through the android.R.styleable#AndroidManifestPermissionTree <permission-tree>
tag in its manifest. A package can only add permissions to trees that were defined by either its own package or another with the same user id; a permission is in a tree if it matches the name of the permission tree + ".": for example, "com.foo.bar" is a member of the permission tree "com.foo".
It is good to make your permission tree name descriptive, because you are taking possession of that entire set of permission names. Thus, it must be under a domain you control, with a suffix that will not match any normal permissions that may be declared in any applications that are part of that domain.
New permissions must be added before any .apks are installed that use those permissions. Permissions you add through this method are remembered across reboots of the device. If the given permission already exists, the info you supply here will be used to update it.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.