使用QandroidJniObject未调用的三个函数之一
One of three functions not being called using QAndroidJniObject
这是从我的自定义Java类调用三个函数的代码:
QAndroidJniObject datafile = QAndroidJniObject::fromString(path);
QAndroidJniObject password = QAndroidJniObject::fromString("asimpletest");
QAndroidJniObject::callStaticObjectMethod("org/qcolocrypt/AESCrypt",
"AESCryptInit",
"(Ljava/lang/String;Ljava/lang/String;)V;",
password.object<jstring>(),
datafile.object<jstring>());
QAndroidJniObject decrypted_data = QAndroidJniObject::callStaticObjectMethod("org/qcolocrypt/AESCrypt",
"decrypt",
"()Ljava/lang/String;");
QAndroidJniObject fname = QAndroidJniObject::callStaticObjectMethod("org/qcolocrypt/AESCrypt",
"getFilename",
"()Ljava/lang/String;");
QAndroidJniObject status = QAndroidJniObject::callStaticObjectMethod("org/qcolocrypt/AESCrypt",
"getStatus",
"()Ljava/lang/String;");
这是其中三个功能的Java代码:
不工作的一个:
public static void AESCryptInit (String passwd, String datafile){
// Initializing variables.
rawdata = null;
status = "";
fileName = datafile;
Log.i("[QCOLOCRYPT]","The filename is " + datafile);
// Transforming the passwd to 16 bytes.
try {
MessageDigest digester = MessageDigest.getInstance("MD5");
InputStream in = new ByteArrayInputStream(Charset.forName(encoding).encode(passwd).array());
byte[] buffer = new byte[NCHARS];
int byteCount;
while ((byteCount = in.read(buffer)) > 0) {
digester.update(buffer, 0, byteCount);
}
keyBytes = digester.digest();
}
catch(Exception e){
status = "Error in key generation: " + e.toString();
}
// Initilizing the crypto engine
try {
cipher = Cipher.getInstance(algorithm);
}
catch(Exception e){
status = "Error in intialization: " + e.toString();
}
secretKeySpec = new SecretKeySpec(keyBytes, "AES");
ivParameterSpec = new IvParameterSpec(keyBytes);
}
和两个工作的
// Getting status
public static String getStatus(){return status;}
public static String getFilename() {
Log.i("[QCOLOCRYPT]","Getting the file name");
return "The Filename is: " + fileName;
}
当我收到日志消息和其他两个的返回值时,没有打印其调试消息,因此未调用非工作函数。logcat似乎没有显示任何错误,所以我很茫然。我叫错吗?
好的,所以这并不是一个答案。这更像是一个解决方法,我可以使用功能,但是我唯一可以做的方法是返回字符串。我已经尝试使用(参数)i的整数;作为签名,但我遇到了同样的问题。我修改了Java函数以返回状态字符串,更改了签名以反映这一点,一切正常。虽然很奇怪。
相关文章:
- 为什么 getch 在按下函数或箭头键时返回三个值?
- 我的动态链接队列在同一输出流中调用时不正确地输出三个返回函数
- 如何通过通用引用或std::forward将这三个c++模板函数合并为一个
- 三个参数函数模板令人困惑的示例
- 在第三个 pary 函数中使用矢量引用时出现意外错误
- 访问三个不同的变量在C++中形成三个不同函数中的一个文件
- Java opencv inRange 阈值函数将我的图像分成三个不同的图像
- 如何使用三个参数化构造函数的rand()函数初始化对象的数组
- 将函数两个向量合并为第三个向量
- 使用QandroidJniObject未调用的三个函数之一
- (C++)如何创建一个函数来接收两个排序的链表并返回出现在两个列表中的第三个元素列表
- 排序函数的第三个参数如何工作
- C 除了使用TBB :: task_group外,我如何一次运行三个不同的Parallel_for函数
- 接受子引用作为参数的父函数(或三个相互依赖类的冒险)
- 如何从另一个函数中访问一个功能,从C 中的第三个访问
- 函数,它接受三个参数:指向双数组的指针、指向最小值的指针和指向最大值元素的指针
- 调用第三个函数后如何返回第一个函数
- 如何将三个函数转换为一个泛型函数
- 用多个参数和三个函数从Java调用c++
- 设计问题——一个函数调用所有三个函数