I use an IntentService to handle large file-downloads in my app. But when i want to cancel the download i call stopService(intent)
. However the onDestroy()
method is been called but the download doesn't stop.
What else do i have to do to cancel the download?
Thanks.
I have not figured this out myself, but I send an Intent
with:
intent.putExtra("pause", "yes");
startService(intent);
And then I override public int onStartCommand(Intent intent, int a, int b)
inside the IntentService
(which is not recommended) and seeing that "pause" is "yes" I set a static boolean mPaused
to true
. If you have a loop in onHandleIntent
, add && !mPaused
in the loop condition.
Of course this is all 'bad' code and a hack... but I hope somebody else chimes in with the correct way of doing this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With