'Application restarting and reopen after change permission from setting with keeping the last version

I'm developing an Android app that contains MainActivity that contains also BottomNavigationView with some Fragments . When I click on the second icon of the BottomNavigationView, it's color changes and that's fine till now , but when I put app in the background and change any permission from setting to deny and reopen the app , the app is restarting (reopen) but with the previous values of the previous version and when I click back , the previous version is there !! and didn't destroyed !! this cause some crashes if I was in another fragment , also changes in the design because the activity starts again with the default values and the new values are still there , If you faced a problem like this , please help me .



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source