Control screen luminosity
-
I have an application which scrolls automatically some data in a listview, without user action. After about 30 seconds the screen luminosity goes at half value and after another 30 seconds the screen goes off. I'd like to be able to prevent this from the application. From what I searched so far it seems it has to do with the screensaver, but Qt5.3 (that I am using) has no suport for controlling the screensaver.
-
What kind of device is this? Android, iOS, some other embedded device?
If you can set the power settings on the screen to stay awake at all times, then I think you can fix it. On android at least you can prevent the screen to sleep. On embedded devices you write your own driver to do this or just set some settings on existing driver.
However, this is not related to QtQuick.
-
Ok, then you should take a look at this:
Permission you need to change power settings:
http://developer.android.com/reference/android/Manifest.permission.html#WAKE_LOCKJava method to change power settings:
http://developer.android.com/reference/android/os/PowerManager.WakeLock.htmlExample of using C++ to access Java in a Qt application:
http://doc-snapshot.qt-project.org/qt5-5.3/qtandroidextras-notification-example.html -
Try to add this new method on example qtandroidextras-notification-example in the file NotificationClient.java
@
public static void keepScreenOn() {
Window w = m_instance.getWindow();
if ( w == null ) {
Log.v(TAG, "null window");
} else {
w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
@Add these imports in the file NotificationClient.java
@
import android.view.WindowManager;
import android.view.Window;
import android.util.Log;
@Call it in main.cpp just after QGuiApplication.
@
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
"keepScreenOn");@I tried to add it after line
@QQuickView view;@and after line
@view.show();@
but it not works for me.
-
Try to add this new method on example qtandroidextras-notification-example in the file NotificationClient.java
@
public static void keepScreenOn() {
Window w = m_instance.getWindow();
if ( w == null ) {
Log.v(TAG, "null window");
} else {
w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
@Add these imports in the file NotificationClient.java
@
import android.view.WindowManager;
import android.view.Window;
import android.util.Log;
@Call it in main.cpp just after QGuiApplication.
@
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
"keepScreenOn");@I tried to add it after line
@QQuickView view;@and after line
@view.show();@
but it not works for me.