Blackberry 10 screenshot error

134 views Asked by At

I am trying to use bb:system::screenshot like so

request.setTarget("sys.pim.uib.email.previewer");

  // Set the action that the target app should execute
  request.setAction("bb.action.VIEW");

  // Set the MIME type of the data
  request.setMimeType("message/rfc822");

  // Specify the location of the data
  request.setUri(QUrl("pim:message/rfc822:" + QString::number(accountId) +":" + QString::number(messageId)));

  InvokeTargetReply *reply = invokeManager.invoke(request);

  sleep( 2 );

  //Screenshot
  bb::system::Screenshot screenshot;
  QString filename = screenshot.captureDisplay();
  if (filename.isEmpty()) {
      // Something went wrong
      bb::system::ScreenshotError::Type error = screenshot.error();
  }

  //Close Email
  invokeManager.closeChildCard();

The problem is the filename is always empty and screenshot.error() always has error values. Here's what the debugger says at the "something went wrong" line:

screenshot.error() Error: Multiple errors reported.\ Failed to execute MI command: -var-create - * screenshot.error() Error message from debugger back end: Couldn't find method bb::system::screenshot::error\ Unable to create variable object

Not sure what this means?

EDIT: I moved the screenshot variable definition outside the if statement and see this error:

Name : error
    Details:bb::system::ScreenshotError::PermissionDenied
    Default:bb::system::ScreenshotError::PermissionDenied
    Decimal:2
    Hex:0x2
    Binary:10
    Octal:02

Problem is, I definitely have the permissions set correctly:

  <!-- Request permission to execute native code.  Required for native applications. -->
<permission system="true">run_native</permission>
<permission>access_pimdomain_contacts</permission>
<permission>read_device_identifying_information</permission>
<permission>access_pimdomain_messages</permission>
<permission>bbm_connect</permission>
<permission>access_pimdomain_calendars</permission>
<permission>use_camera</permission>
<permission>use_camera_desktop</permission>
<permission>use_gamepad</permission>
<permission>access_internet</permission>
<permission>access_location_services</permission>
<permission>record_audio</permission>
<permission>read_personally_identifiable_information</permission>
<permission>access_pimdomain_notebooks</permission>
<permission>access_notify_settings_control</permission>
<permission>access_phone</permission>
<permission system="true">_sys_inject_voice</permission>
<permission>read_phonecall_details</permission>
<permission>access_pimdomain_calllogs</permission>
<permission>control_phone</permission>
<permission>post_notification</permission>
<permission system="true">_sys_use_consumer_push</permission>
<permission>run_when_backgrounded</permission>
<permission system="true">_sys_run_headless</permission>
<permission system="true">_sys_headless_nostop</permission>
<permission>access_shared</permission>
<permission>access_sms_mms</permission>
<permission>access_wifi_public</permission>

From the docs, I need "Permissions: The application must have the use_camera_desktop and access_shared permissions to use this feature."

1

There are 1 answers

0
Richthofen On BEST ANSWER

This is apparently a bug in the Blackberry simulator going as far back as the 10.2 simulator (the 10.2 simulator is when the screenshot library was introduced so you can't go back farther than that.) I confirmed this with a Blackberry Developer Advisor. (found here, sign-in required http://supportforums.blackberry.com/t5/Native-Development/Error-Capturing-and-saving-a-screen-shot-in-BB10-c/td-p/3112490)