title: How to avoid running the same async task again until it got finished
body: <p>I have implement the pull to refresh functionality in my android app and i am using async task for fetching the data from server when user do pull to refresh, but sometimes if user do pull to refresh multiple times , it request the server multiple times so duplicate data comes . I want to avoid this situation, is there any way by which i can check if the async task is running than dont run the same task again until it finished.</p>
  
  <p>This is my function in which i am calling async task</p>
  
  <pre><code> public void refresh()
  {
  
  if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB &amp;&amp; !mSharedPreferences.getString("SN","").equals("") )            
              new getfeeds(getSherlockActivity()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (AppConstants.URL_FEED_MAIN+mSharedPreferences.getString("SN",null)+"/newer/0/"));
           else if( !mSharedPreferences.getString("SN","").equals("")  )
               new getfeeds(getSherlockActivity()).execute((AppConstants.URL_FEED_MAIN+mSharedPreferences.getString("SN","")+"/newer/0/"));       
   }
  </code></pre>
  
  <p>i want to put an condition in that if and elseif statement so it check some condition before starting getfeeds async task until previous getfeeds execution is finished</p>