I have written an app using the official API to upload to Google drive, this works perfectly. However I can\'t find anyway to cancel an upload. I\'m running it in an ASync
I've been looking for an answer for a long time as well. The following is the best I could come up with.
Store the Future
object anywhere you want (use Object
or Void
):
Future
Call this code (Java 8):
try
{
ExecutorService executor = Executors.newSingleThreadExecutor();
future = (Future
To cancel, call:
future.cancel(true);
This solution hasn't produced any nasty side effects so far, unlike stopping a thread (deprecated), and guarantees a cancel, unlike interrupting.