Trying to make a game so how can i hide Status Bar on android



  • Hello,

    I am trying to do a game so i want to hide the status bar, at least i need the status bar height for calculation for my screen resolition.

    Is there anyway to do in Qt c++ code to hide status bar or take status bar height?

    Not; i tried

       setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    

    it doesnt worked

    http://www.mattsbits.co.uk/user_media/screenshots/android_2_3_statusbar.png

    i need hide the status bar.

    Thanks.



  • Try add:

    <activity
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    

    to AndroidManifest

    But You may also call it through JNI:

    #include <QtAndroidExtras/qandroidfunctions.h>
    #include <QtAndroidExtras/qandroidjnienvironment.h>
    #include <QtCore/qdebug.h>
    
    void setFullScreen() {
      QAndroidJniObject activity = QtAndroid::androidActivity();
      if (activity.isValid()) {
        QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
        if (window.isValid()) {
          const int FLAG_KEEP_SCREEN_ON = 128;
          const int FLAG_FULLSCREEN = 1024;
    //      const int FLAG_FORCE_NOT_FULLSCREEN = 2048;
          window.callMethod<void>("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON | FLAG_FULLSCREEN);
          QAndroidJniEnvironment env;
          if (env->ExceptionCheck())
            env->ExceptionClear();
        }
      }
    }
    

    Then invoke MainWindow in main.cpp:

    mainWindow.showFullScreen();
    

    or call showMaximized() in its constructor

    (Bonus ;-) probably You would like to keeps screen on). It requires additional permission: <uses-permission android:name="android.permission.WAKE_LOCK"/>



  • @SeeLook

    showFullScreen() is working bot i didnt edit menifest, i am new on that.

    thanks a lot =)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.