3

I want to know how to get a permission and licenses alert during installation in BlackBerry Java.

I am using GPS, so there should be one alert displayed before installation that this application uses GPS. The user may then save or deny the request.

Thanks

Nate
  • 31,017
  • 13
  • 83
  • 207

2 Answers2

2

You can use ApplicationPermissionsManager

Example for GPS:

    ApplicationPermissions requestedPermissions = new ApplicationPermissions();         
    requestedPermissions.addPermission(ApplicationPermissions.PERMISSION_LOCATION_API));    
    //You can add additional required permissions to the batch of requested permissions

    boolean allGranted = ApplicationPermissionsManager.getInstance().invokePermissionsRequest(requestedPermissions);
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
0

Mister Smith's answer is good, but there's one more piece needed. You mentioned that you wanted the permission alert during installation. In order to get that, you need something else, too.

For BlackBerry apps, you can define alternate entry points. This can create multiple instances of your application. A common reason for this, for example, would be to define one normal UI application, and another background application, to listen for push notifications.

In this case, you can create an application instance to simply run at startup, and run the permissions check (shown in Mister Smith's answer). When you define the entry point for the permission-checking "application", you will set it to Auto-run on startup in the BlackBerry_App_Descriptor.xml file, which will cause it to start as soon as the app installs.

See here for defining alternate entry points.

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • Note also that the requirement appears to be to display a GPS alert message, regardless of whether the User has actually allowed GPS. If the User allows it, the permissions check should be run, and if the check indicates permissions have not been set for Location, then the User should be informed. if the User does not allow GPS, then there is no need to include Location in the list of permissions requested. This alert should be displayed in a start-up alternate entry as Nate suggests. You will need to make sure it is only run once. – Peter Strange Dec 03 '13 at 23:15