+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onSaveInstanceState(savedInstanceState);
+
+ // Get a handle for the tab WebView. A class variable cannot be used because it gets out of sync when restarting.
+ WebView tabWebView = (WebView) tabLayout;
+
+ // Save the scroll Y position if the tab WebView is not null, which can happen if a tab is not currently selected.
+ if (tabWebView != null) {
+ savedInstanceState.putInt("scroll_y", tabWebView.getScrollY());
+ }
+ }