所以我使用以下代码试图调用PlayBook相机,并让用户拍照。然后应该将图片作为文件路径String返回给我。
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本身的问题?据我所知,我已经完成了与示例文档相同的所有操作。
答案 0 :(得分:0)
我发现问题,我想我们没有正确的功能或功能有错误的顺序,当我使用以下功能时相机工作(我在webwork示例kitchenconink中找到它): ////////////////////////////////////////////////// ////////////////////////////////////////////////
<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="*"/>
/////////////////////////////////////////////// ////////////////////////////// 祝你好运!