In my application there have one activity (MainActivity)and four fragment . when my app goes in splitView (Multi Window mode) the onCreate() method get called in MainActivity and that reason first fragment get loaded when i goes to multiWindow mode. How to stop recalling onCreate() method when app goes in splitView.
Asked
Active
Viewed 644 times
2
-
May be this can help: https://stackoverflow.com/questions/42718275/how-to-detect-when-device-goes-to-multi-window-mode-of-android-n – saibbyweb Feb 05 '19 at 07:42
-
thanks . I get solution of problem . I am add android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" in manifastFile – kulkarni swati Feb 05 '19 at 10:21
-
Can I post it as answer? – saibbyweb Feb 05 '19 at 10:26
1 Answers
2
To avoid calling onCreate() and onDestroy() method in activity when application goes on MultiWIndow mode (SplitView) write android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" in Manifest file.

kulkarni swati
- 39
- 7
-
This will also prevent recreating when switching between landscape and portrait. Generally you're better off correctly implementing saved state and have the activity recreated. Handling config changes manually makes sence for fullscreen activities such as camera, gallery or games. – Eugen Pechanec Feb 05 '19 at 10:54
-
I don't know your code, but if your fragment is reloaded every time then rewrite it like so `if (savedInstanceState == null) { supportFragmentManager.beginTransaction() ... }`. This will only setup your fragment once. You don't have to change manifest. – Eugen Pechanec Feb 05 '19 at 10:56