Android: fix deprecated onCreateDialog() methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index ad9aeb5..408d9c6 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -1233,9 +1233,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/** Result of current messagebox. Also used for blocking the calling thread. */
protected final int[] messageboxSelection = new int[1];
- /** Id of current dialog. */
- protected int dialogs = 0;
-
/**
* This method is called by SDL using JNI.
* Shows the messagebox from UI thread and block calling thread.
@@ -1279,7 +1276,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
runOnUiThread(new Runnable() {
@Override
public void run() {
- showDialog(dialogs++, args);
+ messageboxCreateAndShow(args);
}
});
@@ -1299,8 +1296,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return messageboxSelection[0];
}
- @Override
- protected Dialog onCreateDialog(int ignore, Bundle args) {
+ protected void messageboxCreateAndShow(Bundle args) {
// TODO set values from "flags" to messagebox dialog
@@ -1329,7 +1325,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
// create dialog with title and a listener to wake up calling thread
- final Dialog dialog = new Dialog(this);
+ final AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(args.getString("title"));
dialog.setCancelable(false);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@@ -1415,7 +1411,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
// add content to dialog and return
- dialog.setContentView(content);
+ dialog.setView(content);
dialog.setOnKeyListener(new Dialog.OnKeyListener() {
@Override
public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
@@ -1430,7 +1426,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
});
- return dialog;
+ dialog.show();
}
private final Runnable rehideSystemUi = new Runnable() {