You create a new instance of SaveImageTask , and then call its execute method, passing it String arguments ( execute takes varargs).
new SaveImageTask().execute("foo", "bar");
Edit
Since your AsyncTask uses Context , you need to pass it through the constructor.
public class SaveImageTask extends AsyncTask<String, String, String> { private Context context; private ProgressDialog pDialog; String image_url; URL myFileUrl = null; Bitmap bmImg = null; public SaveImageTask(Context context) { this.context = context; } ... }
Then call AsyncTask from your Activity as follows:
new SaveImageTask(this).execute("foo", "bar");
Tyler treat
source share