public void onPause() { super.onPause(); if(dialog != null && dialog.isShowing()) { dialog.dismiss();
protected boolean isMatching( Dialog dialog ) { return dialog.isShowing(); } })
Dialog dialogFrg=dialog.getDialog(); if(dialogFrg!=null && dialogFrg.isShowing()) { // no need to call dialog.show(ft, "DatePicker"); } else { // call dialog.show(ft, "DatePicker"); }
private Dialog dialog = null; private void showDialog() { if(dialog!=null && dialog.isShowing()) return; /** Here create dialog */ }
Dialog passwordDialog = new Dialog(SettingsActivity.this); holder.butDelete.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(!passwordDialog.isShowing()) { passwordDialog.show(); } } });
protected boolean isMatching( Dialog dialog ) { return windowTitle.equals(dialog.getTitle()) && dialog.isShowing(); } })
NotReadyDialogFragment dialog = ((NotReadyDialogFragment) getActivity().getFragmentManager().findFragmentByTag("MyDialogTag")); if (dialog != null) { Dialog df = dialog.getDialog(); if (df != null && df.isShowing()) { df.dismiss(); } }
Dialog passwordDialog = new Dialog(SettingsActivity.this); holder.butDelete.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(!passwordDialog.isShowing()) { passwordDialog.show(); } } });
Dialog d = b.show(); // here you got the dialog object when u showing you dialog first if (d!=null &&d.isShowing()){ d.dismiss(); }
Use below provided code for reference toward solving this issue. // Keep this as member variable to the class final Dialog dialog = new Dialog(context); // your new method model public void showCustomDialog() { // Here check this if(dialog != null && dialog.isShowing()){ // Decide if you want to display a new one, if yes then write below code first dialog.dismiss(); dialog = null; // Display a new dialog code here }else{ // Dialog is no visible, diaply it here } }
public static boolean isActiveDialog(Dialog dialog) { if (!dialog.isShowing()) return false; Window dialogWindow = dialog.getWindow(); if (dialogWindow != null) { View decorView = dialogWindow.getDecorView(); if (decorView != null) return decorView.hasWindowFocus(); } return false; }
private android.view.ViewGroup.LayoutParams alertLayoutParams = null; private Dialog alertViewDialog = null; private LinearLayout cvPopupView; public void showPopupView(View popupView) { if (cvPopupView == null) cvPopupView = new LinearLayout(ctContext); else cvPopupView.removeAllViews(); cvPopupView.addView(popupView); if (alertViewDialog == null) { alertViewDialog = new Dialog(ctContext); alertViewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); } if (alertLayoutParams == null) { alertLayoutParams = new android.view.ViewGroup.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); } if (!alertViewDialog.isShowing()) { alertViewDialog.addContentView(cvPopupView, alertLayoutParams); alertViewDialog.show(); } }
ImageButton apple = (ImageButton) findViewById(R.id.imageButton1); apple.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(Fruits.this); WebView view = new WebView(Fruits.this); view.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); builder.setView(view); final Dialog d = builder.create(); // save a Dialog reference here d.show(); view.loadUrl("file:///android_asset/apple.gif"); gifIsPlaying = true; new Handler().postDelayed(new Runnable() { public void run() { gifIsPlaying = false; if (d.isShowing()) { // dismiss dialog if still showing d.dismiss(); } } }, PLAYING_TIME_OF_GIF); } });
for (int i = 0; i < numDialogs; i++) { final Dialog dialog = mManagedDialogs.valueAt(i); if (dialog.isShowing()) { dialog.dismiss();
public void showDialog() { View content = activity.getLayoutInflater().inflate(R.layout.dialog, null, false); // This makes top LinearLayout background transparent, without this, // it will be all white covering fullscreen. content.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Dialog dialog = new AlertDialog.Builder(context) .setView(content).create(); dialog.show(); // needs to be done before window changes Window window dialog.getWindow(); window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); View overlay = content.findViewById(R.id.overlay); overlay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (dialog.isShowing()) { dialog.cancel(); } } }); }
if(dialog!=null&&dialog.isShowing()){ dialog.dismiss(); }else{
Dialog mDialog; public void howtoplayvideo(){ mDialog = new Dialog(this,android.R.style.Theme_DeviceDefault_NoActionBar_Fullscreen); mDialog.setContentView(R.layout.dialogbox); Button exit = (Button) mDialog.findViewById(R.id.done); exit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDialog.dismiss(); } }); mDialog.show(); } @Override public void onRealTimeMessageReceived(RealTimeMessage rtm) { byte[] buf = rtm.getMessageData(); int button = (int) buf[0]; switch (button) { case 1: if (mDialog != null && mDialog.isShowing()) mDialog.dismiss(); break; }}
public void openDialog() { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.custom_dialog); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); final EditText edUsername = (EditText) dialog.findViewById(R.id.edUsername); final EditText edPassword = (EditText) dialog.findViewById(R.id.edPassword); Button btnDissmissDialog = (Button) dialog.findViewById(R.id.btnOk); btnDissmissDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (dialog != null) { if (dialog.isShowing()) { String strUsername = edUsername.getText().toString().trim(); String strPasswird = edPassword.getText().toString().trim(); dialog.dismiss(); } } } }); dialog.show(); }
Dialog dialog; @Override protected void onPreExecute() { //initialize inflate and customize your dialog dialog.setMessage("Loading..."); dialog.setIcon(R.drawable.youricon); dialog.setCancelable(false); dialog.show(); } @Override protected void onPostExecute(Void result) { if (dialog.isShowing()) dialog.dismiss(); }