Androidでダイアログボックスを表示しています.また、これらのダイアログオブジェクトはグローバルではありませんが、それらのスコープは使用されているメソッド内にあります.バックグラウンドからフォアグラウンドに来るとき、ダイアログが表示されているかどうかを識別する必要がありますビューがダイアログを表示しているかどうかを識別する方法を知るには、はいの場合はダイアログを閉じます。以下は私のコードです:
public void reentersecuredpin()
{
final Dialog dialog = new Dialog(MainActivity.this,android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.successful_securepin_creation);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
dialog.setCancelable(true);
Button btn_Ok;
btn_Ok=(Button)dialog.findViewById(R.id.btn_Ok_successful_created_pin);
TextView text1_success,text2_success;
text1_success=(TextView)dialog.findViewById(R.id.text1_success);
text2_success=(TextView)dialog.findViewById(R.id.text2_success);
text1_success.setText("You have entered wrong Pin");
text2_success.setText("Please re-enter your password again");
btn_Ok.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
dialog.cancel();
}
});
dialog.show();
}
だから私が背景から前景に来るとき:
@Override
protected void onResume()
{
super.onResume();
background_to_foreground_dialog();
}
background_to_foreground_dialog() は別のダイアログを表示します。ここで直面している問題は、background_to_foreground_dialog() が別のダイアログにダイアログを描画することです (ユーザーがバックグラウンドに移動した場合)。background_to_foreground_dialog() を描画する前に、前のダイアログを閉じるにはどうすればよいですか。