I am trying to call a Java static function in Qt C++ class using QAndroidJniObject with a string parameter.

在Qt c++类中,我尝试使用带有字符串参数的QAndroidJniObject调用一个Java静态函数。

This is my Java class having function which i am calling

这是我调用的Java类。

        public class StatusBar{

        public static void setStatusBarBackgroundColor(Activity activity,String colorPref) {

// My code


         }  
        }

I am calling this function from C++ as

我用c++来调用这个函数。

void ECApplicationInfo::changeStatusBarColor(QString color)
{
  QAndroidJniObject::callStaticMethod<void>( 
                  "com/ezeecube/ezeesync/StatusBar",
                  "setStatusBarBackgroundColor",
                  "(Landroid/app/Activity;)V",
                   activity,color);
}

I am getting the following error

我得到了以下错误。

error: cannot pass objects of non-trivially-copyable type 'class QString' through '...' activity,color);

错误:不能通过“……”的活动,颜色);

How can i get rid of this error

我怎样才能摆脱这个错误呢?

2 个解决方案

#1


3

The definition of your function signature is not correct. You should also specify the second argument which has a type of Ljava/lang/String;. Also you should convert QString to jstring and the pass it as an argument :

函数签名的定义不正确。您还应该指定具有Ljava/lang/String类型的第二个参数;还应该将QString转换为jstring,并将其作为参数传递:

QAndroidJniObject::callStaticMethod<void>( 
                  "com/ezeecube/ezeesync/StatusBar",
                  "setStatusBarBackgroundColor",
                  "(Landroid/app/Activity;Ljava/lang/String;)V",
                   activity,QAndroidJniObject::fromString(color).object<jstring>());

更多相关文章

  1. 错误:警告:无法从javaldx读取路径
  2. Java错误:线程“main”中的异常java.lang.ArrayIndexOutOfBoundsE
  3. 不幸的是,在声明按钮时,模拟器中出现了错误
  4. javaScript里的string的match函数返回值的问题
  5. 当我运行.jar时,在java.library中会得到一个“No lwjgl”。路线”
  6. 导入证书后的Java Keytool错误,“Keytool error: Java .io。FileN
  7. Cassandra Java驱动程序错误 - 所有主机尝试查询失败连接已关闭
  8. 线程“main”中的异常java.lang.RuntimeException:无法编译的源代
  9. java httpclient访问某些网页报403错误

随机推荐

  1. android 系统级 bug audio latency
  2. android 颜色值 代码
  3. 在native c++里打log
  4. 使用TextView实现跑马灯Marquee
  5. Android(安卓)自定义View onDraw方法详解
  6. Android 剪贴板详解
  7. Android开发 设置控件边角半圆
  8. 简单研究Android View绘制一 测量过程
  9. android:imeOptions属性
  10. Android 编译时注解