我已经从 github 设置了屏幕截图插件,位于此处:
https://github.com/phonegap/phonegap-plugins/tree/master/Android/Screenshot
我按照说明使用 cordova 1.8.1 进行了设置。它成功了,屏幕截图已保存到手机上。然而,cordova 2.0.0 失败了。
截图.java代码:
屏幕截图.js代码:
https://github.com/phonegap/phonegap-plugins/blob/master/Android/Screenshot/www/Screenshot.js
根据一位名叫 Simon MacDonald 的聪明人的建议,我从上面显示的 JS 文件中删除了第 31 行和第 38 行。
但是,当我尝试在 cordova 2.0.0 中使用屏幕截图插件时,我收到以下错误:
ERROR: org.json.JSONException: Value undefined of type java.lang.String cannot be converted to JSONArray.
Error: Status=8 Message=JSON error
file:///android_asset/www/cordova-2.0.0.js: Line 938 : Error: Status=8 Message=JSON error
Error: Status=8 Message=JSON error at file:///android_asset_/www/cordova-2.0.0.js:938
cordova.js 的第 938 行是:
// If error, then display error
else {
console.log("Error: Status="+v.status+" Message="+v.message);
但我几乎可以肯定这是一个兼容性错误。有谁知道这个问题的解决方法,甚至是原因。我有点迷路了。任何帮助表示赞赏。
我用以下代码调用screenshot.js:
function takeScreenShot() {
cordovaRef.exec("Screenshot.saveScreenshot");
}
非常感谢任何帮助。
最佳答案
我刚刚升级它以支持 v2.0.0:
https://github.com/phonegap/phonegap-plugins/commit/88a57e1c232f604f73be5bd82868d711ac235424
关于java - Cordova 2.0.0 中的 Phonegap 屏幕截图插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12424865/