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

Harri Pasanen harri at mpaja.com
Fri Oct 3 09:48:04 CEST 2014


Well, mine is not QML based either, nor is anything related to this in 
the Hangman example.

It is simpler if you resign from the attempt to do everything from C++ 
and write the little bit of Java required.

Harri

On 03/10/2014 08:31, maitai at virtual-winds.org wrote:
>
> 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:
>
>      QAndroidJniObject  qtActivity  =  QtAndroid::androidActivity();
>      QAndroidJniObject  intent("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 
>>> <mailto: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
>>>     <mailto: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  <mailto: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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20141003/0ec0de6d/attachment.html>


More information about the Android-development mailing list