I am trying to make my first app in android studio and I have an issue, I have 2 activities and in both I have
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Log.e(TAG, "onWindowFocusChanged()");
if (hasFocus) {
hideSystemUI();
}
}
private void hideSystemUI() {
Log.e(TAG, "hideSystemUI()");
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
But, when I change my activity to another one, the function is called from both activities, I don't want to destroy activity.
Should I make a third activity that contains this code and then remove from last two activities?