简体   繁体   English

cordova.exec参数中的异常行为

[英]cordova.exec strange behaviour in parameters

Using cordova 2.6, i am calling a plugin using cordova.exec. 使用cordova 2.6,我正在使用cordova.exec调用插件。 The issue is that the parameters if passed in an array element are being cut(truncated from the end by some characters) at the java side. 问题是,如果传递给数组元素的参数在Java端被剪切(从尾部被某些字符截断)。 but if i pass a simple string as a parameter its being passed perfectly fine. 但是,如果我通过一个简单的字符串作为参数,它可以很好地传递。

Passed 5714 characters in string and its going without any isues, but passing 450 characters in an array's first element is cutting the array into about 1/4th of its original length(119) . 字符串中传递了5714个字符,并且没有任何问题,但是在数组的第一个元素中传递了450个字符将数组切成其原始长度的大约1/4(119)。

Then tried the following : 然后尝试以下方法:

  1. Converted the first array element into string.(Checked the typeof using javascript) and passed but did not help. 将第一个数组元素转换为字符串。(使用javascript检查typeof)并传递但没有帮助。

  2. Created a substring of the original array and passed static limits to the substring ie substring(0,4000) etc etc, but to no luck. 创建原始数组的子字符串,并将静态限制传递给该子字符串,即substring(0,4000)等,但没有运气。

  3. Made a clone of the original array and repeated steps 1 and 2 but again no luck. 克隆了原始阵列,并重复了步骤1和2,但再次失败了。

Could someone tell me where the issue is? 有人可以告诉我问题出在哪里吗?

Increased eclipse heap memory and changed to cordova 2.8.1 too, but the same result. 增加了eclipse堆内存,并且也更改为cordova 2.8.1,但结果相同。 :( :(

I got the reason for the behaviour. 我有这个行为的原因。 Inspected many images , and in my execute method of plugin did the following : 检查了许多图像,在我的plugin执行方法中做了以下操作:

int myLength = args.getString(0).length();
Log.v(TAG,Character.toString(args.getString(0).charAt(myLength-1)));

Got the character as = on the plugin/java side. 在插件/ java端将字符设为= And an = is inserted in the base64 string at the end of it. 在末尾的base64字符串中插入=。 It seems that cordova is inserting these delimeters in the base64string. 似乎cordova在base64string中插入了这些分隔符。

PS :Went through phonegap.js and found that the arguments are being packed as JSON.stringify , and after that could not get more. PS:经过phonegap.js,发现参数被打包为JSON.stringify,此后无法得到更多信息。 That how and where the = is inserted. =插入方式和位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM