0

I'm working on an application with multi-language support and I'm reloading my activity after changing app's language with this part of code in my settings fragment. (Unfortunately I can not use recreate() method to reload the activity)

activity.finish();
activity.overridePendingTransition(0, 0);
startActivity(activity.getIntent().putExtra("FromSettings", true));
activity.overridePendingTransition(0, 0);

The problem with this approach is that the activity's fragments back stack gets removed and I can no longer go back to fragments before my settings fragment.

How can i maintain fragments back stack when reloading the activity?

Mohammad Zamanian
  • 751
  • 2
  • 7
  • 19
  • See the link https://stackoverflow.com/questions/11353075/how-can-i-maintain-fragment-state-when-added-to-the-back-stack – Muhammad Yaseen Mar 05 '20 at 10:58
  • @MuhammadYaseen didn't help, what i want is to save the back stack and restore it in activity's next launch. – Mohammad Zamanian Mar 05 '20 at 11:02
  • As far as I know, you might need to store the fragments opened locally and invoke the fragment manually when going back.. other SO'ers correct me if I am wrong... – sanjeev Mar 05 '20 at 11:07
  • the fragment manager manager the list of fragment and transactions if you can somehow keep the fragment of old activity during configuration change , then maybe you can use it access the back stack , and if you retain fragment they will be saved during configuration change but i do't know whether back stack also get saved you should check it. – Abhinav Chauhan Mar 05 '20 at 11:15

0 Answers0