title: Displaying Alert Dialog within Dialog in Android?
body: <p>I have dialog box, its a calculator.Once user click OK button from that calculator, have to calculate free issue/discount , depends on the flag need to show the conformation alter dialog. Up to design &amp; showing alert dialog is ok.</p>
  
  <p>My problem is Dialog calculator is displayed, in there I clicked OK , it showed the Alert Dialog, without wait Alert Dialog result doing result of the code. How can I do , once it get Alert dialog result only need to do remain part.</p>
  
  <p>This is my code:</p>
  
  <pre><code>dialog = new Dialog(SalesActivityGroup.group.getParent());
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  View vLoad = LayoutInflater.from(SalesActivityGroup.group.getParent()).inflate(R.layout.key_pad, null);
  dialog.setContentView(vLoad);       
  android.view.WindowManager.LayoutParams lp= dialog.getWindow().getAttributes();  
  lp.x = xVal;
  lp.y = yVal;
  lp.width = LayoutParams.WRAP_CONTENT;
  lp.height = LayoutParams.WRAP_CONTENT;
  lp.gravity = Gravity.TOP | Gravity.LEFT;
  lp.dimAmount = 0;            
  dialog.getWindow().setAttributes(lp);
  dialog.setCancelable(false);
  keyamDisplay  = (TextView)dialog.findViewById(R.id.keyamDisplay);
  TextView txtName  = (TextView)dialog.findViewById(R.id.txtName);
  txtName.setText("Q");
  
  Button  txtDialogOK = (Button)dialog.findViewById(R.id.txtDialogOK);
  txtDialogOK.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
      dialog.dismiss();
      popup = false;
      try {
  
            String productCode= txtCode.getText().toString();
            String number = txtNumber.getText().toString();
            int iVal = 0;  //getting i value
            if(number != "" &amp;&amp;  !number.equals("")){      
                  iVal = Integer.parseInt(number);
            }         
           String enteredQty = keyAmount.toString();
           String tmpEnterdPrice = txtPrice.getText().toString();
           double enterdPrice = Double.parseDouble(tmpEnterdPrice);
  
  
     if(tmpQty &gt; Double.parseDouble(stk.getText().toString())){
          if(disStockVali.equals("1")) { //Confirmation message if yes no discount , only entered &lt;&lt;Qty&gt;&gt;
              AlertDialog.Builder disco = new AlertDialog.Builder(SalesActivityGroup.group.getParent());
              disco.setMessage("Discount Qty Not Enough!! \n Do you want to continue without discount ?");
              disco.setCancelable(false);
              disco.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                 dialog.dismiss();
                 disStatus ="YES";
               }
              });
  
              disco.setNegativeButton("No", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                  dialog.cancel();
                  disStatus ="NO";
                 }
            });
             disco.setTitle("Qty Not Enough");
             disco.show();
             System.out.println("==disStatus=="+disStatus);
  
             if(disStatus.equals("YES")) {
                System.out.println("==YES YES====");
                System.out.println("=YES=QTY==" + txtQty.getText().toString());
                disPro.setDiscountQty(0);
                disPro.setDiscountProductCode("");
                disPro.setDiscountValue(0.00);
             }else {
                enteredQty = "0";
                txtQty.setText("0");
                valueInDouble = 0.00;
                disPro.setDiscountQty(0);
                disPro.setDiscountProductCode("");
                disPro.setDiscountValue(0.00);
      }
  }
     System.out.println("==2 QTY ==" +txtQty.getText().toString());
     System.out.println("==valueInDouble ==" +valueInDouble);
     double tmpNet = valueInDouble - disPro.getDiscountValue();
     txtVal.setText(df.format(tmpNet)); 
     // TAX calculation
     VatTax vatTax =  calculateLineTax(productCode,Double.parseDouble(txtVal.getText().toString()));
  
       }catch (Exception e) {
     e.printStackTrace();
        }
    dialog.dismiss();
   }
     });
    dialog.show();    
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FqpwF.png" alt="enter image description here"></p>
  
  <p>Please help me out.     </p>