title: Alert Dialog does not dismiss
body: <p>In the below code snippet <code>alertdialog.dismiss</code> is not working don't know why. Logs work fine but the dialog does not dismiss.
      override fun onReceive(context: Context, arg1: Intent) {</p>
  
  <pre><code>        var builder = AlertDialog.Builder(context)
                  .setTitle("Network Error !")
                  .setMessage("Check your internet connection...")
                  .setCancelable(false)
          var alertDialog:AlertDialog = builder.create()
  
              if (isConnectedOrConnecting(context)) {
                      alertDialog.dismiss()
                      Log.i("Network","Alive")
  
              } else{
                  Log.i("Network","Dead")
                  alertDialog.show()
                  //alertDialog.dismiss()
              }
      }
  </code></pre>