I have an Activity say ActivityMain
from this activity I moved to another activity called ActivitySettings
and in settings activity I'm changing the App locale by clicking on a button, and using recreate I achieved the change I need in current activity but when I press back my `ActivityMain' will resume but locale is not updated.
Can some one tell me how to 'Recreate' backstack activities? what will be the correct approach.
I can't call recreate on refresh as it will be infinite loop
In each Activity's
onCreate()
you can maintain thecurrentLangCode
. Check this value inonResume()
, if it differs, you can conclude the locale was change andrecreate()
You can do it as follows:
My Recommendation
If you want to apply it for all the Activities, then simply create BaseActivity as follows:
Extend all Activities from
BaseActivity