Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid AlertDialog Box Not Showing
    primarykey
    data
    text
    <p>I've searched through Stackoverflow, looked at the examples in Android Developer, and some books and I'm just not getting it.</p> <p>I'm trying to show an AlertDialog Box that interrupts the program flow. Most of the examples I've seen don't have code after the dialog box and I need my program to stop executing until the AlertDialog button is pressed. Seems as if the AlertDialog is created from another thread and I'm not sure how to retrieve that thread.</p> <p>Program logic: If the parsing is bad the program will force close. I want to let the user know to restart the program and everything will work. (I'm dropping and recreating tables and they are repopulated when the program starts back up)</p> <p>Here's some code:</p> <pre><code>if(database populated) { ....code..... if(parseok.contentEquals("Error")) { doForceClose(); } displayDate = "Last: " + parseok; //I don't want the program to continue to here. //Rest of code in the method. If I continue the program will Force Close } else do something else </code></pre> <p>Here's the AlertDialog method:</p> <pre><code>private void doForceClose() { String themessage = "Because some of the parameters have changed in the yada yada"; AlertDialog.Builder ad = new AlertDialog.Builder (this); ad.setTitle("Internal Error"); ad.setMessage(themessage); ad.setPositiveButton("Sorry", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); return; } }); ad.create(); ad.show(); } </code></pre> <p>except ad doesn't show and the program continues to its force close.</p> <p>Obviously I'm not getting something. Any ideas?</p> <p>edit: I am in a Class that extends Activity</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload