title: Android Calling Async Task in an activity
body: <p>I have an activity that selects an image from a gridview and it allows you to save the image. I'm using Async Task for all my codes. I seperated my AsyncTask from  a few classes. How do i call them from my activity? How do I pass string back to my AsyncTask. </p>
  
  <p>SingleImageView.class</p>
  
  <pre><code>@Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case R.id.save_image:
                  new SaveImageTask().execute(image_url,context); //&lt;-- The method execute(String...) in the type AsyncTask&lt;String,String,String&gt; is not applicable for the arguments (String, Context)
  
                    return true;
              default:
                  return false;
          }
  </code></pre>
  
  <p>SaveImageTask.class</p>
  
  <pre><code> public class SaveImageTask extends AsyncTask&lt;String, String, String&gt;
      {
          private Context context;
          private ProgressDialog pDialog;
          String image_url;
          URL myFileUrl = null;
          Bitmap bmImg = null;
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
  
              super.onPreExecute();
  
              pDialog = new ProgressDialog(context);  //&lt;&lt;-- Couldnt Recognise
              pDialog.setMessage("Downloading Image ...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
  
          }
  
          @Override
          protected String doInBackground(String... args) {
              // TODO Auto-generated method stub
  
              try {  
                  myFileUrl = new URL(image_url);
                  HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();   
                  conn.setDoInput(true);   
                  conn.connect();     
                  InputStream is = conn.getInputStream();
                  bmImg = BitmapFactory.decodeStream(is); 
              }
              catch (IOException e)
              {       
                  e.printStackTrace();  
              }
              try {       
  
                  String path = myFileUrl.getPath();
                  String idStr = path.substring(path.lastIndexOf('/') + 1);
              File filepath = Environment.getExternalStorageDirectory();
              File dir = new File (filepath.getAbsolutePath() + "/Wallpaper/");
                  dir.mkdirs();
                  String fileName = idStr;
                  File file = new File(dir, fileName);
                  FileOutputStream fos = new FileOutputStream(file);
                  bmImg.compress(CompressFormat.JPEG, 75, fos);   
                  fos.flush();    
                  fos.close();       
              }
              catch (Exception e)
                      {
                          e.printStackTrace();  
                      }
              return null;   
          }
          @Override
          protected void onPostExecute(String args) {
              // TODO Auto-generated method stub
  
              pDialog.dismiss();
  
          }
      }
  </code></pre>