title: Android, How can I close app when in dialog back button is clicked?
body: <p>In my main activity, i call a dialog which is cancelable. I show this dialog when user lunches the app while he is not connected to Internet. therefore, I show this dialog to ask him connect to Internet.</p>
  
  <p>This dialog doesn't have button and I want to close application when user clicks back button. In <code>onKeyDown()</code> method, I'm closing the application (<code>this.finish();</code>) but the problem is when dialog is displaying on screen when user clicks back button, this dialog disappear and my main activity is show.</p>
  
  <p>It seems onKeyDown() just work in main activity not for dialog. How to close my app when dialog is display and user clicks back button?</p>
  
  <p>Thanks</p>
  
  <p>=====>
  <strong>Update</strong></p>
  
  <p>This is the code of my custom dialog:</p>
  
  <pre><code>private void initWarningDialog(){
          dialogWarning = new Dialog(DRMActivity.this, R.style.customDialogStyle);
          dialogWarning.setTitle("Warning!");
          dialogWarning.setContentView(R.layout.dialogwarning);
          dialogWarning.setCancelable(true);
      }
  </code></pre>