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
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified
Accepted Solution

ControlledAccessException on using Display.screenshot()

Dear All,
I am using Display.screenshot() to get a screen shot for the current displayed screen .
my application has all available persmissions set to allow,
it works well in all device application BUT it doesn't work on Facebook and Twitter app
on those apps i got an exception Error: net.rim.device.api.system.ControlledAccessException: Unauthorized attempt to attach to this application,

what is should do to overcome this ?
Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: ControlledAccessException on using Display.screenshot()

as those apps were developed by RIM it could be possible that its not allowed to take screen shots of them without some internal permission that you cannot get.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

so no way to take screen shots from it ?
no work arounds to get those permissions ?
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

Try one of the free screen shooting utilities on App World and see if they are similarly restricted. 

Please use plain text.
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

other screen shots apps working well
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

[ Edited ]

Which statement in your application is throwing the exception?

Please use plain text.
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

this

Display.screenshot(bm);
Please use plain text.
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: ControlledAccessException on using Display.screenshot()

now way to overcome this problem ?
i googled two days trying to solve it but without any results,
!!!!!!!
Please use plain text.
Contributor
krupeshatwork
Posts: 26
Registered: ‎03-25-2012
My Device: none
My Carrier: vodafone

Re: ControlledAccessException on using Display.screenshot()

 

// try tthis code snippet

 

private int dispWidth = Display.getWidth();
private int dispHight = Display.getHeight();
private Bitmap bitmap = new Bitmap(dispWidth,dispHight );

 

private JPEGEncodedImage jImage;
private byte[] bData;

 

 

// run method

 

public void run() {
Display.screenshot(bitmap);
System.out.println("------");

try {
jImage = JPEGEncodedImage.encode(bitmap, 30);
bData = jImage.getData();
System.out.println("-----bData l = "+ bData.length);
}

 

} catch (Exception e) {
System.out.println("------error get data = "+e.toString());
}


}


Regards ,
Krupesh H
Please use plain text.
Trusted Contributor
imre_m
Posts: 160
Registered: ‎11-17-2010
My Device: PlayBook, Z10, Q10

Re: ControlledAccessException on using Display.screenshot()

Could you tell on what OS version and device are you getting the error?

Is your COD signing successful?

 

Otherwise, I would suggest to use the other screenshot method, with the more parameters: public static void screenshot(Bitmap bitmap, int x, int y, int width, int height) (query the display size and orientation using the Display class)

The first one may fail on some devices, especially when the virtual keyboard or some special content is displayed.

 

--
If you find this post useful please Like it.
If it solves your problem please mark as solution.
Please use plain text.