黑莓10截图错误

Blackberry 10 screenshot error

我正在尝试像这样使用 bb:system::screenshot

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();

问题是文件名总是空的,screenshot.error() 总是有错误值。这是调试器在 "something went wrong" 行所说的内容:

screenshot.error() 错误:报告了多个错误。\ 无法执行 MI 命令:-var-create - * screenshot.error() 来自调试器后端的错误消息:找不到方法bb::system::screenshot::error\无法创建变量对象

不确定这是什么意思?

编辑:我将屏幕截图变量定义移到了 if 语句之外,看到了这个错误:

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

问题是,我确实正确设置了权限:

  <!-- 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>

从文档中,我需要“权限: 应用程序必须具有 use_camera_desktop 和 access_shared 权限才能使用此功能。"

这显然是 Blackberry 模拟器中的一个错误,最早可追溯到 10.2 模拟器(10.2 模拟器是在引入屏幕截图库时推出的,因此您不能再往前追溯了。)我通过黑莓开发者顾问。 (在此处找到,需要登录 http://supportforums.blackberry.com/t5/Native-Development/Error-Capturing-and-saving-a-screen-shot-in-BB10-c/td-p/3112490