how to stop AsynchTask in android?
<p>hi guy
m using a asynctask for running a progressbar. i am using it for showing my songs duration.i want that when i press stop Button, the asynctask should be stop and progressbar should reach on initial position.</p>

<pre><code>public class BackgroundAsyncTask extends 
        AsyncTask&lt;Void, Integer, Void&gt; {

        int myProgress;

        @Override 
        protected void onPostExecute(Void result) {
                // TODO Auto-generated method stub
                Toast.makeText(AudioPlayer2.this,         
                        "onPostExecute", Toast.LENGTH_LONG).show();
                seekbar.setClickable(true);  
                }       

        @Override  
        protected void onPreExecute() {   
                // TODO Auto-generated method stub
                Toast.makeText(AudioPlayer2.this,         
                        "onPreExecute", Toast.LENGTH_LONG).show();
                myProgress = 0;  
                //seekbar.setProgress(myProgress);
        }       

        @Override 
        protected Void doInBackground(Void... params) {   
                // TODO Auto-generated method stub
                while(myProgress&lt;100){
                        myProgress++;
                        //seekbar.setProgress(myProgress);
                        publishProgress(myProgress);
                        Log.d("AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", bundleDuration);
                        SystemClock.sleep(2000) ;
                        }
                return null; 
        }       

        @Override
        protected void onCancelled() {
                super.onCancelled();
                //  myProgress=0;
                // seekbar.
                publishProgress(0);
                seekbar.setProgress(0);
        }       

        @Override
        protected void onProgressUpdate(Integer... values) { 
                // TODO Auto-generated method stub
                seekbar.setProgress(values[0]); 
        }       
} 
</code></pre>

<p>//=====================================
for starting and stopping  m using this code</p>

<pre><code>public void onClick(View src) {
    switch (src.getId()) {
    case R.id.buttonStart:
new BackgroundAsyncTask().execute();
          break;
        case R.id.buttonStop:
          backgrondasynctask.cancel(true);
             break;
</code></pre>
