Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 views
in Technique[技术] by (71.8m points)

android - How to kill a Activity and the AsyncTask

i am working on a little game. When I press the backbutton the activity will show a window cancel game yes/no.

If I press Yes i get via finish() back to my MainActivity.

My Problem is, that I can't start the game again, because my Asynctask wasn't finished. I first have to kill the app in the "recently used apps".

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to cancel the AsyncTask in the Activity's onStop.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...