My Question is i need to open SAME FRAGMENT from Navigation Drawer's every List Item 's, and when fragment display, If AsynTask execution is On Going then AsyncTask execution should be cancel.
How can i do it?
I tried so many ways to accomplish this but i failed everytime.
I used asynctaskObject.cancel(true);
So Can anybody please answer. i hope i'll get the result.
Thanks in advance. :)
i found solution of my problem.
We just need to make request in onStop method like below :
This way whenever we request from Navigation Drawer's List Item on Same Fragment, at that time fragment call onStop() method and i just call task.cancel(true);
And Thanks to @MysticMagic. i resolved this issue from your given link.
For forceful
cancel()
to work, you will need to check if its cancelled in doInBackground.Refer this: Why Android AsyncTask doesn’t stop after being cancelled
Hope it helps.