All about Qt on Android QtCon presentation
In this session we’ll see real life examples of using JNI on Android. We’ll start by checking the Qt 5.7 goodies which will make our lives easier, then we’ll see simple examples that you’ll need to use in almost any Qt on Android application, and we’ll end up with an Android Service made with Qt.
In this session we’ll see real life examples of using JNI on Android. We’ll start by checking the Qt 5.7 goodies which will make our lives easier, then we’ll see simple examples that you’ll need to use in almost any Qt on Android application. At the end, we’ll see how to create an Android Service made with Qt, and we’ll see how to use QtRemoteObjects to communicate with that service.
Informative thanks for your presentations I have used them to get going. However I tried the example to keep screen on. I added a comma. but it still have error compiling.
void keepScreenOn(bool on) {
static const int FLAG_KEEP_SCREEN_ON
= QAndroidJniObject::getStaticField( “android/view/WindowManager$LayoutParams”, “FLAG_KEEP_SCREEN_ON” );
QtAndroid::runOnAndroidThread([on, FLAG_KEEP_SCREEN_ON] {
auto window = QtAndroid::androidActivity().callObjectMethod(“getWindow”,
“()Landroid/view/Window;”);
if (on)
window.callMethod(“addFlags”, “(I)V”, FLAG_KEEP_SCREEN_ON);
else
window.callMethod(“clearFlags”, “(I)V”, FLAG_KEEP_SCREEN_ON);
}); //ADDED Comma
}
error:
../src/example/MainWindow.cpp:76:38: error: ‘FLAG_KEEP_SCREEN_ON’ cannot be captured because it does not have automatic storage duration
QtAndroid::runOnAndroidThread([on, FLAG_KEEP_SCREEN_ON] {
^
../src/example/MainWindow.cpp:73:20: note: ‘FLAG_KEEP_SCREEN_ON’ declared here
static const int FLAG_KEEP_SCREEN_ON