Important: Please read the Qt Code of Conduct -

[SOLVED]How to keep the backlight on(Android)?

  • I develop android app with Qt 5.1.0 RC1.
    I want to keep the backlight on.

    @#include <android/native_activity.h>

    ANativeActivity *theActivity;

    but compile error:
    undefined reference to 'ANativeActivity_setWindowFlags'

    Someone can help me?
    thanks a lot.

  • You are missing some libraries in the .pro file probably.

    LIBS += -L$$PWD/../../android-ndk-r8d/platforms/android-14/arch-arm/usr/lib/ -landroid

    INCLUDEPATH += $$PWD/../../android-ndk-r8d/platforms/android-14/arch-arm/usr/include/android
    DEPENDPATH += $$PWD/../../android-ndk-r8d/platforms/android-14/arch-arm/usr/include/android

    You need to replace them with your corresponing directory. I hope that this is enough

    For the anative window flags you might need to include <window.h>

  • Thank you, Moster!

    If it can be useful to anyone, in my case (Qt 5.2.1, QtCreator 3.0.1, Android NDK, Revision 9c):

    1. I added the line "#include <android/window.h>".

    2. In QtCreator I edited the .pro file, in the editor section I clicked with the secondary button to make the contextual menu appear, I chose "Add Library...", I chose "System Library", I clicked on "Browse...", I chose the file [...]/android-ndk-r9c/platforms/android-19/arch-arm/usr/lib/
      I clicked on "Next", a dialog was shown saying "The following snippet will be added to [...]", I clicked on "Finish" and, finally, this line was added to the .pro file:

    unix|win32: LIBS += -landroid

  • By the way, about the code:
    @ANativeActivity *theActivity;
    I've been searching for this for several days :-( : Please, how can you obtain the pointer to the native activity running your Qt app?

  • I don't know how to obtain the pointer to the native activity running your Qt app.
    and that seems to be not necessary.

    I solved by add

  • Thank you, Peterlin, that achieved the same result for me.

    Note: If someone uses Qt 5.2, modifies the file and then that file is automatically overwritten, in my case it was very useful "that article": (people can search there the text "Next, I added a new Activity subclass") and "that example":

Log in to reply