I have an AsyncFacebookRunner that uploads an image to Facebook. I want to create a cancel button that will stop the download.
How can one achieve that?
EDIT:
This is how I use it:
byte[] data = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/photos", params, "POST",
new PhotoUploadListener(dialog), null);
You can always extend the
AsyncFacebookRunnerclass and override therequestmethod.Something like this:
It hasn’t been tested, but should give you the general idea.
Edit
Now that I think about it, this makes little sense, since you want to use the
AsyncFacebookRunnerto make multiple requests and thecancelwill cancel the last request only.I would suggest returning the thread and then have the ability to interupt it somewhere else, but you can’t change the signature of the method like this and creating a new method won’t make it possible to use other
requestmethods defined in theAsyncFacebookRunnerclass.Instead you can do something like:
You’ll need to generate an id somehow for the request, can be something simple like: