Android finish() Activity Not working
<p>I got this error in my codes when i use <code>finish();</code> "The method finish() is undefined for the type SaveImageTask" . Am I missing some declarations or anything. Can someone please guide me on this.     </p>

<pre><code>    public class SaveImageTask extends AsyncTask&lt;String , String , String&gt; {

            private Context context;
            private ProgressDialog pDialog;

            boolean bCancelled=false;
            public SaveImageTask(Context context) {
                this.context = context;
            }

            @Override
            protected void onPreExecute() {
                // TODO Auto-generated method stub

                super.onPreExecute();

                pDialog = new ProgressDialog(context);
                pDialog.setIndeterminate(false);
                pDialog.setCancelable(true);
                pDialog.setOnCancelListener(cancelListener);
                pDialog.show();

            }

            @Override
            protected String doInBackground(String... args) {
                // TODO Auto-generated method stub

                // MY STUFF
                return null;   
            }

            @Override
            protected void onPostExecute(String args) {
                // TODO Auto-generated method stub

                pDialog.dismiss();

            }

            OnCancelListener cancelListener=new OnCancelListener(){
                @Override
                public void onCancel(DialogInterface arg0){
                    bCancelled=true;
                    SaveImageTask.this.finish(); // &lt;&lt;----"The method finish() is undefined for the type SaveImageTask"
                }
            };


        }
</code></pre>
