我尝试在收到新邮件时创建弹出通知。
首先,我想用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();
}
当消息通过JNI到达时显示。
Text.cpp:
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);
}
实际上,我的应用程序在收到邮件时崩溃了。怎么用?