How do I cancel an AsyncTask
<p>I am using an Asynctask as the loop controller for a game and noticed that the thread created kept on running after the activity was finished.</p>

<p>I realised that was the correct behaviour of a separate thread and then I tried hunting down answers on how to end the thread when the app enters onPause.</p>

<p>I found lots of similar questions but no direct answers but eventually came up with a method so I'm going to answer my own question here to hopefully help others in future. (And to receive improvements to my answer as well)</p>
