JNI-安卓系统上的警报对话框
JNI - Alert dialog on Android
我想在带有JNI的Android上显示简单的警报对话框。这是我的代码:
myApp.cpp:
QtAndroid::androidActivity().callMethod<void>("popupDialogMain", "()V");
主要活动:
public void popupDialogMain()
{
Log.d("Alert Dialog ", "33333333--------------------------");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
Log.d("Alert Dialog ", "44444--------------------------");
builder.setMessage("Look at this dialog!")
.setCancelable(true)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//do things
}
});
AlertDialog alert = builder.create();
alert.show();
}
每当我想使用我的应用程序时,它就会崩溃,这是它的日志:
D/Alert Dialog (28644): 33333333--------------------------
D/Alert Dialog (28644): 44444--------------------------
F/art (28644): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION:id
F/art (28644): art/runtime/check_jni.cc:65] in call to NewGlobalRef
F/art (28644): art/runtime/check_jni.cc:65] "QtThread" prio=10 tid=11 Runnable
F/art (28644): art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x12c4e440 self=0xa1433400
F/art (28644): art/runtime/check_jni.cc:65] | sysTid=28825 nice=-11 cgrp=apps sched=0/0 handle=0xaef7ec00
F/art (28644): art/runtime/check_jni.cc:65] | state=R schedstat=( 1790287538 286358026 2178 ) utm=151 stm=28 core=0 HZ=100
F/art (28644): art/runtime/check_jni.cc:65] | stack=0xaed4c000-0xaed4e000 stackSize=1012KB
F/art (28644): art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
F/art (28644): art/runtime/check_jni.cc:65] native: #00 pc 00004640 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
有什么解决的建议吗?
使用此:
public void popupDialogMain()
{
Log.d("Alert Dialog ", "33333333--------------------------");
final Context context = getApplicationContext();
Handler h1 = new Handler(context.getMainLooper());
h1.post(new Runnable() {
@Override
public void run() {
popupDialogMain1();
}
});
}
public void popupDialogMain1()
{
Log.d("Alert Dialog ", "44444--------------------------");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
Log.d("Alert Dialog ", "5555--------------------------");
builder.setMessage("Look at this dialog!")
.setCancelable(true)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//do things
}
});
AlertDialog alert = builder.create();
alert.show();
}
相关文章:
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 当对话框被接受时,如何用参数调用槽
- WinAPI 在单击第一个对话框上的按钮控件并销毁第一个对话框后创建第二个对话框
- 如何多次询问来自QML对话框的输入?
- 选择文件对话框错误
- 自定义对话框(源自QDialog)不会关闭(Android)
- 如何在 MFC 对话框中使用 OnDraw
- 在C++中创建文件夹选取器对话框的最简单方法是什么?
- 从资源视图访问对话框时出现问题
- 如何检测窗口当前是否正在运行模式对话框?
- "最小化"按钮不会出现在 MFC 对话框中
- 如何获取QNetworkConfiguration UserChoice对话框?
- 表单显示对话框函数错误,并且不执行下面的语句
- 如何在 VC6 中的对话框中将图标设置为按钮
- 如何基于类定义构建对话框窗口?(比如Django的模型系统)
- 在MFC对话框应用程序中全天候检查系统时间
- 自定义系统对话框 - Windows Mobile 6.5
- JNI-安卓系统上的警报对话框
- 增加系统链接不显示MFC对话框
- 一个基于c++窗口对话框的程序如何获取系统的一个状态