[Android-development] using getwindow.setFlags from a JNI activity object

BogDan bog_dan_ro at yahoo.com
Fri Oct 3 08:36:05 CEST 2014



1- You can't set window flags from Qt thread. Those flags must be set from Android thread.
2- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON[1] is an integer not a string!


Cheers,
BogDan.
[1] 
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_KEEP_SCREEN_ON


________________________________
From: "maitai at virtual-winds.org" <maitai at virtual-winds.org>
To: Android Development <Android-development at qt-project.org> 
Sent: Friday, October 3, 2014 9:31 AM
Subject: Re: [Android-development] using getwindow.setFlags from a JNI activity object



My app is not qml-based, but widget-based, so I am trying to do that using QAndroidJniObject...
My best guess so far is something like that:
QAndroidJniObjectqtActivity=QtAndroid::androidActivity();
QAndroidJniObjectintent("android/content/Intent","()V");
QAndroidJniOject param=QAndroidJniObject::fromString("WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON");
intent.callObjectMethod("addFlags","(I)Landroid/content/Intent;",param.object<jobject>());
qtActivity.callObjectMethod("startActivity","(Landroid/content/Intent;)V",intent.object<jobject>());
 
but of course it does work because it's not the right way to set param. I suppose I need to retrieve the jint value for FLAG_KEEP_SCREEN_ON so I can use it in the intent, but I don't know how to achieve that. 
 
Le 02-10-2014 23:15, Harri Pasanen a écrit :

>
>
>
>Inheriting from QtActivity is straight forward.
>
>I have for example:
>
>public class JavaTalker extends org.qtproject.qt5.android.bindings.QtActivity
>...
>
>
>For a more complete example see:
>
>http://blog.qt.digia.com/blog/2013/12/12/implementing-in-app-purchase-on-android/
>
>
>Hope this helps,
>
>Harri
>
>On 02/10/2014 22:56, Fernando Pelliccioni wrote:
>
>>
>>
>>
>>On Mon, Sep 29, 2014 at 5:05 PM, <maitai at virtual-winds.org> wrote:
>>
>>Hello,
>>>
>>>I'm trying to set/clear FLAG_KEEP_SCREEN_ON when GPS positionning is
>>>activated/deactivated. I read that I should be doing something like
>>>activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
>>>
>>>So I'm trying to get an activity instance with
>>>QAndroidJniObject qtActivity = QtAndroid::androidActivity();
>>>or
>>>QAndroidJniObject qtActivity =
>>>QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
>>>"activity", "()Landroid/app/Activity;");
>>>
>>>and then no luck, whatever I tried concerning callMethod() and
>>>similar....
>>>
>>>Any clue?
>>>
>>>Thanks
>>>Philippe Lelong
>>>_______________________________________________
>>>Android-development mailing list
>>>Android-development at qt-project.org
>>>http://lists.qt-project.org/mailman/listinfo/android-development
>> 
>>Hi,
>> 
>>I'm stuck with the same problem. 
>>All the Java examples I saw, set the FLAG_KEEP_SCREEN_ON flag on the onCreate() method of the Activity subclass, like:
>> 
>>public class MyActivity extends Activity {
>>//...
>>    @Override
>>    protected void onCreate(Bundle x) {
>>        super.onCreate(x);
>>        //...
>>        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
>>        //...
>>    }
>>}
>> 
>>How can we inherit from QtActivity and put code on the onCreate() function? (in Qt 5.3)
>> 
>>Thanks and regards,
>>Fernando Pelliccioni.
>>
>>
>>_______________________________________________
Android-development mailing list Android-development at qt-project.org http://lists.qt-project.org/mailman/listinfo/android-development 
>
>
>_______________________________________________
Android-development mailing list Android-development at qt-project.org http://lists.qt-project.org/mailman/listinfo/android-development 
 
 

_______________________________________________
Android-development mailing list
Android-development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/android-development



More information about the Android-development mailing list