开发者

Is there a way to differentiate between normal Activity destruction and one caused by rotation?

开发者 https://www.devze.com 2023-02-28 12:07 出处:网络
I have an Activity that start some asynctasks. I want these tasks to stop, when my Activity is destroyed \"normally\" (like calling finish() / the user pressing the back button / etc.), but continue r

I have an Activity that start some asynctasks. I want these tasks to stop, when my Activity is destroyed "normally" (like calling finish() / the user pressing the back button / etc.), but continue running when the user only rotates the device.

Canceling these tasks, and handling the rotation works just fine, I just can't combine the two.

So is there a way to tell during the "onDestroy()" callback, that the Activity is destroyed bec开发者_StackOverflowause of a configurational change (rotation), or because of some other cause (back button e.g.)?


You can call isChangingConfigurations() on your Activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号