1

所以我正在使用以下代码来尝试调用 PlayBook 相机,并让用户拍照。然后应该将图片作为文件路径字符串返回给我。

captureImage: function() {
    App.log("App.captureImage > Invoked");
    try {
        blackberry.media.camera.takePicture(App.takePictureComplete, App.cameraClosed, App.cameraError);
    } catch (err) {
        App.log("App.captureImage > Error Occured: " + err);
    }

    App.log("App.captureImage > Complete");
},

takePictureComplete: function(filePath) {
    App.log("App.takePictureComeplete > Image taken and file retrieved: " + filePath);
    App.origin.attr('src', filePath);
},
cameraClosed: function() {
    App.log("App.cameraClosed > Camera closed.");
},
cameraError: function(err) {
    App.log("App.cameraError > ERROR: " + err);
},

这是发生的事情的日志。请注意,任何回调函数或 catch 块中都没有日志记录。

app.js:153 App.captureImage > Invoked
app.js:153 App.captureImage > Complete
index.html:187 TypeError: 'null' is not an object (evaluating 'response.Response')

引发异常的第 187 行是 WebKit 代码的一部分,包含以下内容:

request.onreadystatechange = function() {
   // continue if the process is completed
   if (request.readyState == 4 && request.status == 200) {
       // retrieve the response
       var response = JSON.parse(request.responseText, jsonReviver);
       responseCallback(response.Response); //LINE 187
   }
};

我在这里做错了什么,或者这是 API 本身的问题?据我所知,我所做的一切都与示例文档相同。

4

1 回答 1

0

我找到了问题,我猜我们没有正确的功能或功能顺序错误,当我使用以下功能时相机工作(我在webwork示例厨房水槽中找到它): ////////// ///////////////////////////////////////// /////////////////////////////////

<rim:permissions>
    <rim:permit>access_shared</rim:permit>
    <rim:permit>record_audio</rim:permit>
    <rim:permit>read_geolocation</rim:permit>
    <rim:permit>use_camera</rim:permit>
    <rim:permit>read_device_identifying_information</rim:permit>
</rim:permissions>

<!-- 
    Universal APIs: 
        The following features are available on both Smartphone and Tablet OS
-->
<feature id="blackberry.app" required="true" version="1.0.0.0"/>
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.system" required="true" version="1.0.0.0"/>
<feature id="blackberry.system.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.ui.dialog" required="true" version="1.0.0.0"/>
<feature id="blackberry.utils" required="true" version="1.0.0.0"/>

<feature id="blackberry.media.camera" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.microphone" required="true" version="1.0.0.0"/>
<feature id="blackberry.identity" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.file" required="true" version="1.0.0.0"/>
<feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>

<!-- 
    Smartphone APIs: 
        The following features are available ONLY on Smartphone
--> 
<feature id="blackberry.ui.menu" required="true" version="1.0.0.0"/>
<feature id="blackberry.identity.phone" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.AddressBookArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.CalendarArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.MapsArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.MemoArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.MessageArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.PhoneArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.SearchArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.invoke.TaskArguments" required="true" version="1.0.0.0"/>
<feature id="blackberry.message" required="true" version="1.0.0.0"/>
<feature id="blackberry.message.sms" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Address" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.category" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Contact" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Memo" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0"/>
<feature id="blackberry.pim.Task" required="true" version="1.0.0.0"/>

<feature id="blackberry.audio" required="true" version="1.0.0.0"/>
<feature id="blackberry.audio.Player" required="true" version="1.0.0.0"/>

<feature id="blackberry.find" required="true" version="1.0.0.0"/>
<feature id="blackberry.phone.Phone" required="true" version="1.0.0.0"/>
<feature id="blackberry.phone.PhoneLogs" required="true" version="1.0.0.0"/>

<feature id="blackberry.push" required="true" version="1.0.0.0"/>
<feature id="blackberry.find" required="true" version="1.0.0.0"/>

<!-- 
    Tablet OS APIs: 
        The following features are available ONLY on Tablet OS
    ...
-->
<!--
COMMENT THE FOLLOWING WHEN BUILDING USING THE SMARTPHONE SDK.

<feature id="blackberry.payment" required="true" version="1.0.0.0"/>
-->

<access subdomains="true" uri="*"/>

///////////////////////////////////////// /////////////////////////// 祝你好运!

于 2012-07-26T09:49:34.563 回答