I have made custom video player in which i am starting video in async task and it works perfect but when i lock the screen, video is running inspite of this. Please recommend any good solution.
Asked
Active
Viewed 74 times
2 Answers
4
You can create the class object of your Asynch task class
in your activity like below example
customAsynchTask mytask = new customAsynchTask();
and then you can stop the execution of the method as per your requirement
mytask.cancel(true);
like in your case you can use the .cancel on onpause of your activity .

kuljeet singh
- 2,792
- 2
- 12
- 15
2
Use like this:
@Override
protected void onDestroy()
{
super.onDestroy();
asyncTask.cancel(true);
}

N J
- 27,217
- 13
- 76
- 96

anirban karak
- 732
- 7
- 20