How to keep the screen on in Qt for android?

前端 未结 3 958
孤独总比滥情好
孤独总比滥情好 2021-01-18 02:54

I found a couple of solutions how to do that in Java, but did not find how can I do it in QML or Qt. I know that first I should set the WAKE_LOCK permission in

3条回答
  •  孤城傲影
    2021-01-18 03:50

    You can achieve this by editing the java file used by qt itself. In installation path under src in android path you will find QtActivity.java file. In the onCreate function add the below line

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    

    WAKE_LOCK permission in AndroidManifest.xml also should be added.

    Build the project, it will work fine.

提交回复
热议问题