I have a native C
function (with JNI of course) that should callback a java method to display a dialog but this dialog is never displayed.
This is how this works:
- C code calls a java method
- The java method logs something
- Then it calls
showDialog(SOME_ID)
- The
onCreateDialog(SOME_ID)
is called - The dialog is constructed using
AlertDialog.Builder
- When I call
AlertDialog alert = builder.create()
the application just stops right there (without crashing or freezing) but only when this call starts from the C code.
The code is as follows:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case SOME_ID:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Message");
builder.setPositiveButton(...);
builder.setNegativeButton(...);
AlertDialog alert = builder.create();
System.out.println("...Never called from JNI");
return alert;
}
return null;
}
In 6 I mean that I log something before and after calling builder.create()
but the log after the create
method is never called so the method never returns and the dialog is never created. I have a button to trigger the dialog and, as expected, it works.
I did another test, I printed getApplicationContext()
calling directly from onCreate()
and from onCreateDialog()
(called from C code) and it is the same, because one of the first things I thought was that the onCreateDialog() was being called from another Context or something.
Do you have any idea why the dialog is not displaying?