title: Alert dialog calling multiple times
body: <p>Every time user enters in aplication, onResume() is calling. If user doesn't respond on alert dialog, then dialogs just accumulate. I want to check is dialog already shown.</p>
  
  <p>I found great answers given here: <a href="https://stackoverflow.com/questions/8135195/prevent-dialog-to-be-opened-multiple-times-when-resuming-activity?rq=1">Prevent dialog to be opened multiple times when resuming activity</a> and here <a href="https://stackoverflow.com/questions/12560931/how-do-i-show-only-one-dialog-at-a-time">How do I show only one Dialog at a time?</a> but always was some error while implementing that in my code</p>
  
  <p>Alert dialog </p>
  
  <pre><code>private AlertDialog.Builder showGPSDialog(Context con) {
  
      AlertDialog.Builder builder = new AlertDialog.Builder(con);
      builder.setTitle("Enable GPS");
      builder.setMessage("Please enable GPS");
  
      builder.setPositiveButton("Enable", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              startActivity(
                      new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
          }
      });
      builder.setNegativeButton("Ignore", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
          }
      });
      return builder;
  }
  </code></pre>
  
  <p>onResume()</p>
  
  <pre><code>LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
      boolean isEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  
      if(!isEnabled) {
          showGPSDialog(MapsActivity.this).show();
      }
  </code></pre>