我研究了用于android的Qt通知程序示例:https://doc.qt.io/qt-5/qtandroidextras-notification-example.html在此示例中,使用两个参数调用Java方法,如下所示:
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>());
}我很难理解我应该在这里传递什么参数来调用有两个参数的函数,而不是一个参数。例如,该函数当前只有一个参数:
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());
}我可以在方法本身( public static void notify(String s, String x) )中添加另一个,但是如何处理cpp部分呢?
发布于 2019-09-26 21:37:37
它应该是
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
"notify",
"(Ljava/lang/String;Ljava/lang/String;)V",
javaNotification.object<jstring>(),
somethingelse.object<jstring>());正如here所解释的那样。
https://stackoverflow.com/questions/58117256
复制相似问题