title: How to prevent method to be called twice?
body: <p>I want to check programmatically whether the function is called or not. If it is called before, then do not allow and ignore to be called for the second time, if not then let button to call. Why i need to do this is because of i have a longClick button to run certain functionality, if user forgot to do this then however user will click another button which i will place the same functionality. I need to prevent running same function for twice.</p>
  
  <pre><code>public class ActivityA extends Activity{
  
  private static boolean isScreenShotTaken = false;
  
  blankcard.setOnLongClickListener(new OnLongClickListener() {
  
         if(!isScreenShotTaken)
              {
                  Bitmap bitmap = takeScreenshot();
                  saveBitmap(bitmap);
                  isScreenShotTaken = true;
  
              }
  
          return false;
          }
  });
  
  
  
  btnsend.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
  Intent intent = new Intent(Templates.this, MailCard.class);
  intent.putExtra("name", Name);
  
  if(!isScreenShotTaken)
              {
                  Bitmap bitmap = takeScreenshot();
                  saveBitmap(bitmap);
                  isScreenShotTaken = true;
              }
  
  startActivity(intent);             
  
          }
      });
  
  
  public Bitmap takeScreenshot() {
  
  // code exist here
  //if called once, second call ignore
  
  }
  
  public void saveBitmap(Bitmap bitmap) {
  
  // code exist here
  //if called once, second call ignore
  
    }
  }
  </code></pre>
  
  <p>Thank you for suggestions. </p>