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

maitai at virtual-winds.org maitai at virtual-winds.org
Fri Oct 3 08:31:52 CEST 2014


 

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/ [2]
> 
> 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 [1] 
> 
> 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 [1]

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

 

Links:
------
[1] http://lists.qt-project.org/mailman/listinfo/android-development
[2]
http://blog.qt.digia.com/blog/2013/12/12/implementing-in-app-purchase-on-android/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20141003/6b1abbcd/attachment.html>


More information about the Android-development mailing list