M
M
MdaUZH2016-08-26 08:55:50
Android
MdaUZH, 2016-08-26 08:55:50

How to keep AsyncTask on screen rotation?

Hello everyone)
When you rotate the screen, you need to save AsyncTask
The onRetainNonConfigurationInstance method is deprecated, what should I use instead of it?
They recommend Fragment#setRetainInstance(true), but I don't use fragments and don't understand how to save an object using this, I can't google examples either..
Please tell me, I will be very grateful

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Perelygin, 2016-08-26
@MdaUZH

I don't get it when it's out of date. It's just not recommended to use onRetaineNonConfigurationInstance directly overriding it, but use onRetainCustomNonConfigurationInstance and you'll be happy. And to receive the saved object through getLastCustomNonConfigurationInstance(). I don't understand why it's so hard to read the official documentation? Or give a proof, where it is written that this is all outdated or deprecated?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question