0

Like it was asked before, if you have that in you Qt code for Android:

ANativeActivity* theActivity = <something>;

ANativeActivity_setWindowFlags( theActivity,
            AWINDOW_FLAG_DISMISS_KEYGUARD, 0 );

How can you obtain a pointer to the native activity running your Qt app (the <something> bit)?

Thanks!

Ganton
  • 208
  • 2
  • 10

1 Answers1

0

I am not very possitive if you can get a C++ pointer to the Java QtActivity object, as they live in two different worlds.

However, you could achieve what you need through the use of QAndroidJniObject which is available starting Qt 5.2. Following is an outline:

Step 1: Create a C++ class called MyCppClass with a function called setWindowFlag(int flag, int val).

Step 2: Create a Java class called MyJavaClass with a method called setActivity(Activity activity). Create another method called setWindowFlag(int flag, int val) where you set the window's flag using Android API.

Step 3: In your Java class QtActivity, call MyJavaClass.setActivity(this). I do this in method onCreate() and before loading the Qt application.

Step 4: In MyCppClass, use QAndroidJniObject to bind C++ function setWindowFlag() to Java method MyJavaClass.setWindowFlag().

More detailed information can be found on the documentation page of QAndroidJniObject.

jonathanzh
  • 1,346
  • 15
  • 21