Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Qt-使用JNI的弹出式通知_Java_Android_Qt_Android Ndk_Java Native Interface - Fatal编程技术网

Java Qt-使用JNI的弹出式通知

Java Qt-使用JNI的弹出式通知,java,android,qt,android-ndk,java-native-interface,Java,Android,Qt,Android Ndk,Java Native Interface,我正在尝试在收到新消息时创建弹出通知首先,我想用Java创建一个简单的对话框并对其进行测试 Text.java: public static void popUpDialog() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( context); // set title alertDialogBuilder.setTitle("Your Title"

我正在尝试在收到新消息时创建弹出通知
首先,我想用Java创建一个简单的对话框并对其进行测试

Text.java:

public static void popUpDialog()
{
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            context);

      // set title
      alertDialogBuilder.setTitle("Your Title");
      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      // show it
       alertDialog.show();

}
            mid = m_env->GetStaticMethodID(g_clazz, "popUpDialog", "()V");

            if (messageType == TextMessage)
                m_env->CallStaticVoidMethod(g_clazz, mid, jsReceivedMessage);
            else
            {
                jstring jsPreparedMessage = m_env->NewStringUTF(messageTypeStr(messageType).c_str());

                m_env->CallStaticVoidMethod(g_clazz, mid, jsPreparedMessage);
                m_env->DeleteLocalRef(jsPreparedMessage);
            }
并在消息通过JNI到达时显示它

Text.cpp:

public static void popUpDialog()
{
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            context);

      // set title
      alertDialogBuilder.setTitle("Your Title");
      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      // show it
       alertDialog.show();

}
            mid = m_env->GetStaticMethodID(g_clazz, "popUpDialog", "()V");

            if (messageType == TextMessage)
                m_env->CallStaticVoidMethod(g_clazz, mid, jsReceivedMessage);
            else
            {
                jstring jsPreparedMessage = m_env->NewStringUTF(messageTypeStr(messageType).c_str());

                m_env->CallStaticVoidMethod(g_clazz, mid, jsPreparedMessage);
                m_env->DeleteLocalRef(jsPreparedMessage);
            }

实际上,我的应用程序在收到消息时崩溃了。如何使用它?

“事实上,我的应用程序在收到消息时崩溃了。”然后你应该在问题中包含堆栈跟踪。一件看起来很奇怪的事情是,你试图将字符串传递给
popUpDialog
,即使该方法不带任何参数。