Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing a dialog twice after pressing home key and turn back to app
    primarykey
    data
    text
    <p>I'm developing an Android 2.2 app.</p> <p>I use a dialog to ask user for his nickname. This is my source code:</p> <pre><code>private void showDialog() { //set up dialog final Dialog dialog = new Dialog(UserStatsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.createuserrow); dialog.setOnDismissListener(this); //set up button Button button = (Button) dialog.findViewById(R.id.saveUser); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView nameTextView = (TextView)dialog.findViewById(R.id.userName); userNickName = nameTextView.getText().toString().trim(); if ((userNickName.length() &gt; 0) &amp;&amp; (userNickName.length() &lt; 9)){ saveUser = true; dialog.dismiss(); } } }); //now that the dialog is set up, it's time to show it dialog.show(); } public void onDismiss(DialogInterface arg0) { try { if (saveUser) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); User.saveUser(getApplicationContext(), userNickName); Editor editor = prefs.edit(); editor.putString(USER_NAME, userNickName); editor.putBoolean(FIRST_TIME_RUN, false); editor.commit(); loadPreferences(); } } catch (Exception ex){ Log.e(Constants.APP_TAG, "UActivity: " + ex.getMessage()); showAlert(this.getString(R.string.errorClose)); } } </code></pre> <p>If I press home key while dialog is shown. When I start app again, and I click on save button, dialog is shown again.</p> <p>I've debug my code and it is working perfectly, but the dialog is still open.</p> <p>What's happening?</p> <p>Thanks.</p>
    singulars
    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.
    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