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.
This is my function in which i am calling async task
public void refresh()
{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && !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/"));
}
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