黑莓10截图错误

时间:2015-06-23 14:48:03

标签: c++ blackberry screenshot blackberry-cascades

我正在尝试使用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();

问题是文件名始终为空,screenshot.error()始终具有错误值。这是调试器在"出错的地方所说的内容"行:

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>

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

1 个答案:

答案 0 :(得分:0)

这显然是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