Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

How to - Invoke a Permissions request with other applications also requesting permissions

by BlackBerry Development Advisor on ‎11-26-2010 11:15 AM (5,294 Views)

The ApplicationPermissionsManager API offers a way to streamline the request for application permissions to improve the user experience. The API allows an application to request all required permissions at one time and tell the user why the permissions are needed. Applications are also able to determine which permissions they have and if its is possible to get the desired level of permissions.


However, concurrent requests for permissions were not possible until BlackBerry® Device Software, Bundle 1342. If the application permissions screen was open when another application (or another entry point of the same application) requested permissions, the request would fail with an exception in some cases or would simply fail silently with no request shown to the user. The exception seen was an IllegalArgumentException, with the message "object already exists". This is due to the single allowed permissions screen before the limitation was fixed.


The attached sample code shows how to make permission requests in the background which account for these situations more gracefully.

  • Since only one permissions request can be handled at a time, the sample code foregrounds a hidden permissions screen in case the user had dismissed it or another application had taken the foreground. 
  • After foregrounding any prior screens, the applications own request is queued up using the ApplicationPermissionsManager API.
  • If it fails with the IllegalArgumentException "object already exists", then the request is re-queued when the application is foregrounded again, since the user must handle the existing permission request first.
  • The sample also handles instances where the user has put the permissions request into the background but tries to run the application again, and it has been altered to not show any the main UI until the permissions have been accepted. This is not always the best choice of user experience, but may be desired by some applications.
Users Online
Currently online: 8 members 580 guests
Please welcome our newest community members: