Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save AsyncTask class object in onSaveInstanceState()

Tags:

android

is this possible to save AsyncTask class object on rotation and reuse it again.

  public class MyTask extends AsyncTask<Void, Void, Integer>
    {

    }

any good solution. Thanks

like image 973
Monty Avatar asked Nov 20 '25 23:11

Monty


1 Answers

is this possible to save AsyncTask class object on rotation and reuse it again.

Use onRetainNonConfigurationInstance() or a retained fragment.

thanks for reply but onRetainNonConfigurationInstance() deprecated after 3.0

That is because they recommend that you use a retained fragment instead. If you are not using fragments, use onRetainNonConfigurationInstance().

like image 132
CommonsWare Avatar answered Nov 22 '25 11:11

CommonsWare