Phonegap Screenshot plugin in Cordova 2.0.0

自闭症网瘾萝莉.ら 提交于 2019-12-02 15:03:09

问题


I have set up the screenshot plugin from github, located here:

https://github.com/phonegap/phonegap-plugins/tree/master/Android/Screenshot

I set it up as instructed and with 1.8.1 of cordova. It worked and the screenshot was saved to the phone. However it fails with cordova 2.0.0.

Screenshot.java code:

https://github.com/phonegap/phonegap-plugins/blob/master/Android/Screenshot/src/org/apache/cordova/Screenshot.java

Screenshot.js code:

https://github.com/phonegap/phonegap-plugins/blob/master/Android/Screenshot/www/Screenshot.js

Due to the advice of a very clever man called Simon MacDonald, I removed line 31 and 38 from the JS file shown above.

However when I try to use the screenshot plugin with cordova 2.0.0 I receive these errors:

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

line 938 of the cordova.js is:

 // If error, then display error
    else {
        console.log("Error: Status="+v.status+" Message="+v.message);

but im almost certain this is a compatibility error. Does anyone know a fix for this, or even a reason. Im abit lost. Any help is appreciated.

I call the screenshot.js with this code:

function takeScreenShot() {
cordovaRef.exec("Screenshot.saveScreenshot");

}

Any help massively appreciated.


回答1:


I just upgraded it to support v2.0.0:

https://github.com/phonegap/phonegap-plugins/commit/88a57e1c232f604f73be5bd82868d711ac235424



来源:https://stackoverflow.com/questions/12424865/phonegap-screenshot-plugin-in-cordova-2-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!