[英]Qt call java method with more than 1 argument
I examining the Qt Notifier example for android: https://doc.qt.io/qt-5/qtandroidextras-notification-example.html In this example, a Java method is called with 2 parameters, like this: I examining the Qt Notifier example for android: https://doc.qt.io/qt-5/qtandroidextras-notification-example.html In this example, a Java method is called with 2 parameters, like this:
void NotificationClient::updateAndroidNotification()
{
QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification);
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
"notify",
"(Ljava/lang/String;)V",
javaNotification.object<jstring>());
}
I am having hard time understanding what parameters I should pass in here to call the function with 2 parameters, not one.我很难理解我应该在这里传递哪些参数来调用 function 有 2 个参数,而不是一个。 For instance, the function currently takes 1 parameter:
例如,function 当前采用 1 个参数:
public static void notify(String s)
{
if (m_notificationManager == null) {
m_notificationManager =
(NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
m_builder = new Notification.Builder(m_instance);
m_builder.setSmallIcon(R.drawable.icon);
m_builder.setContentTitle("A message from Qt!");
}
m_builder.setContentText(s);
m_notificationManager.notify(1, m_builder.build());
}
I can add another one in the method itself ( public static void notify(String s, String x)
), but how to handle the cpp part?我可以在方法本身中添加另一个(
public static void notify(String s, String x)
),但是如何处理 cpp 部分?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.