У меня отображается приложение AlertDialog.Builder.Когда я поворачиваю экран, я получаю сообщение об ошибке «приложение утекло».Как отменить AlertDialog в событии onPause ()?Я не вижу методов для Ad.cancel ().
Обновление : код отредактирован для рабочей модели.
private AlertDialog inputDlg;
...
@Override
protected void onPause ()
{
// close dialog if it's showing
if (inputDlg != null)
if (inputDlg.isShowing ())
inputDlg.dismiss ();
super.onPause ();
}
...
private void dlgUserPrompt (Context c)
{
// Set an EditText view to get user input
final EditText input = new EditText (c);
AlertDialog.Builder Ab = new AlertDialog.Builder (this);
Ab.setTitle("title");
Ab.setMessage("I won't explode if you rotate this");
Ab.setView(input);
inputDlg = Ab.show ();
}