Not necessarily butit is a good practice to stop using any resources allocated to your app
while it was in foreground or doing some useful stuff for the user for example downloading/uploading some data from internet, after it's purpose is finished.
It is the same as closing a file or database
when it is no longer required. Even if you remove the above code from onStop()
, it won't affect your app ( if it is not used by some other process) but canceling asynctask will save memory and cpu cycles eventually battery
.
Hope this helps.