Welcome!

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

Reply
Developer
theappspod
Posts: 122
Registered: ‎11-12-2010
My Device: Dev Alpha
My Carrier: N/A
Accepted Solution

Permissions when saving a screenshot

Hi All

 

My app takes a copy of its screen and saves it in the picture library. On the simulator this works fine. On a real device, a popup appears asking for permission to take the screen shot (which is to be expected). However, when I give permission by clicking Allow all it does is save a white image.

 

I have googled and found code that checks for permission using ApplicationPermissions.SCREEN_CAPTURE (now PERMISSION_RECORDING) and even this does not work.

 

Any help with this would be greatly appreciated.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Permissions when saving a screenshot

[ Edited ]

In my experience, you will get that for the first image.  The second one should work fine.  Give it a try.

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Permissions when saving a screenshot

I know this is an issue on OS5. I've had the same problem.

 

It's not much of a workaround but what I did was re-create the image before saving it. It's a bit of a hack and it's not something I would recommend but it got the job done when I needed it.

Please use plain text.
Developer
theappspod
Posts: 122
Registered: ‎11-12-2010
My Device: Dev Alpha
My Carrier: N/A

Re: Permissions when saving a screenshot

Thanks Peter, I will try this. So when you say save it again, do you literally mean save the image twice using the same file name?
Please use plain text.
Developer
theappspod
Posts: 122
Registered: ‎11-12-2010
My Device: Dev Alpha
My Carrier: N/A

Re: Permissions when saving a screenshot

Thanks Dionysus - this is on OS6. Did you simply create a new bitmap object and copy from the original or did you create a bitmap object and draw the screen objects on it?
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Permissions when saving a screenshot

[ Edited ]

Basically the first time you do it, it will pop up the permissions screen independently of your app, and give your app a white screen as a result of the capture.  If the user gives you permission, the next time it will work.

 

But the best approach is to ask for the permission before you try to capture the screen shot.  it is actually really quite easy to check if you have permission and if you don't, then to ask for it.  Once you have permission, then capture the screen shot.

 

The PermissionsAPIDemo sample does not quite match this use case, but if you look at the code supplied, I think you will find it is not that hard to change. 

Please use plain text.
Developer
theappspod
Posts: 122
Registered: ‎11-12-2010
My Device: Dev Alpha
My Carrier: N/A

Re: Permissions when saving a screenshot

Hi Peter

 

Thanks again for your continued help - it is appreciated.

 

I tried manually checking the permissions and setting as follows:

 

ApplicationPermissionsManager manager = ApplicationPermissionsManager.getInstance();

int current = manager.getPermission(ApplicationPermissions.PERMISSION_SCREEN_CAPTURE);

 

if (current != ApplicationPermissions.VALUE_ALLOW) {

ApplicationPermissions permissions =

new ApplicationPermissions();

permissions.addPermission(ApplicationPermissions.PERMISSION_SCREEN_CAPTURE);

manager.invokePermissionsRequest(permissions);

}

 

The code above uses the depreciated SCREEN_CAPTURE but I also tried it with its replacement, RECORDING.

 

When the app started up I saw the dialog asking for permission and I gave it permission, then it displayed another permissions dialog explaining that permission was required to save the screenshot.  I accepted this as well and still the same problem - white image (even if saved twice).  What on earth am I doing wrong?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Permissions when saving a screenshot

[ Edited ]

Can you confirm that on subsequent screenshots you do not get a prompt asking you for permissions?  By the look ofit you did not change the permissions. 

 

You can also check and set permissions "manually" for your Application.  You will find it in Options

On OS 6.0+, it is

  • Options (spanner icon)
  • Device
  • scroll down to Application Management
  • find your app and click on it
  • Edit Permissions. 
Please use plain text.
Developer
theappspod
Posts: 122
Registered: ‎11-12-2010
My Device: Dev Alpha
My Carrier: N/A

Re: Permissions when saving a screenshot

Hi Peter

 

Yes I can confirm that on subsequent saves the permissions dialog is not shown.

 

When I go to manually change the permissions I get the following:

 

Connections - Custom

Interactions - Custom

User Data - Allow

 

I can not change Interactions or Connections to Allow - it goes back to Custom

 

Still the white image.

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Permissions when saving a screenshot

From the Permissions screen, select the "Interactions" drop down, press the BB menu key and select "Expand".  You will see a list of the individual permissions, which will include Recording.  What option do you have set for this?  What options do you have available in the drop down? 

Please use plain text.