title: AlertDialog showing multiple Dialogs on top of each other?
body: <p>I have this method in my GPSTracker:</p>
  
  <pre><code>public void showSettingsAlert() {
      final AlertDialog.Builder alertDialog = new AlertDialog.Builder(myContext);
  
      // Setting Dialog Title
      alertDialog.setTitle("GPS Settings");
  
      // Setting Dialog Message
      alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
  
      // Setting Icon to Dialog
      // alertDialog.setIcon(R.drawable.delete);
  
      // On pressing Settings button
      alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
              myContext.startActivity(intent);
          }
      });
  
      // on pressing cancel button
      alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              dialog.cancel();
          }
      });
  
      alertDialog.show();
  }
  </code></pre>
  
  <p>When I am running it, I keep getting like 10 dialogs at once on top of each other, so basically I can then press 10times cancel or something like that, how do I fix it?
  I read about</p>
  
  <pre><code>final AlertDialog alert = alertDialog.create();
  if(alert.isShowing()) {
  alert.dismiss();
  }
  else {
  alert.show();
  }
  </code></pre>
  
  <p>But that didnt work for me, I am still getting multiple dialogs over each other... Can someone help me out please? Basically I am calling if(gps.isEnabled()) gps.showSettingsAlert(); on my Activity.</p>
  
  <pre><code>if (itemsArrayList.get(position).getCoordinates() == null || !gps.canGetLocation()) {
              holder.distance.setText("Distance not available");
              gps.showSettingsAlert();
          }
  </code></pre>