The code runs on real phones with Android 4.0 (API 14) to 10 (API 29) and on SDK phone emulator with Android R (API 30).
Write the theme for splash activity in style resources.
 <!--Splash screen theme-->
  <style name="SplashTheme" parent="@style/Theme.AppCompat.NoActionBar">
  <item name="android:windowFullscreen">true</item>
  <item name="android:windowBackground">@color/colorSplashBackground</item>
  </style>
It's enough. No code is need to hide bar for splash activity.
Main activity.
Use the theme.
<!-- Base application theme. -->
    <style name="myAppTheme" parent="@style/Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
    </style>
Write code in MainActivity class.
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    // Hide bar when you want. For example hide bar in landscape only
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        hideStatusBar_AllVersions();
    }
    setContentView( R.layout.activity_main );
    // Add your code
    }
Implement methods.
@SuppressWarnings("deprecation")
void hideStatusBar_Deprecated() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {  // < 16
        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {  // 16...29
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        ActionBar ab = getSupportActionBar();
        if (ab != null) { ab.hide(); }
        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}
@TargetApi(Build.VERSION_CODES.R) // >= 30
void hideStatusBar_Actual() {
    View decorView = getWindow().getDecorView();
    decorView.getWindowInsetsController().hide(WindowInsets.Type.statusBars());
}
void hideStatusBar_AllVersions(){
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
        hideStatusBar_Deprecated();
    } else {
        hideStatusBar_Actual();
    }
}