| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /*
- * Copyright (c) 2012-2023 Daniele Bartolini et al.
- * SPDX-License-Identifier: MIT
- */
- package com.example.myapplication;
- import android.app.NativeActivity;
- import android.os.Bundle;
- import android.view.View;
- public class CrownActivity extends NativeActivity
- {
- static
- {
- System.loadLibrary("crown");
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Init additional stuff here (ads, etc.)
- }
- @Override
- public void onDestroy() {
- // Destroy additional stuff here (ads, etc)
- super.onDestroy();
- }
- @Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- if (hasFocus) {
- hideSystemUI();
- }
- }
- private void hideSystemUI() {
- // Enables regular immersive mode.
- // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
- // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE
- // Set the content to appear under the system bars so that the
- // content doesn't resize when the system bars hide and show.
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- // Hide the nav bar and status bar
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- );
- }
- private void showSystemUI() {
- // Shows the system bars by removing all the flags
- // except for the ones that make the content appear under the system bars.
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- );
- }
- }
|