Saturday, November 19, 2011

Android Add Permission Dynemically

public abstract boolean addPermission (PermissionInfo info)
Since: API Level 1
Add a new dynamic permission to the system. For this to work, your package must have defined a permission tree through the <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, "" is a member of the permission tree "".
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.
infoDescription of the permission to be added.
  • Returns true if a new permission was created, false if an existing one was updated.
SecurityExceptionif you are not allowed to add the given permission name.

No comments:

Post a Comment