Using JNI
Unsolved
Mobile and Embedded
-
Hi,
i want to do the following with Qt QAndroidJniObject:wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "My Tag");
The problem is that i can not do the pipe ( | ) with qt.
My code isQAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); if ( activity.isValid() ) { QAndroidJniObject serviceName = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Context","POWER_SERVICE"); if ( serviceName.isValid() ) { QAndroidJniObject powerMgr = activity.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;",serviceName.object<jobject>()); if ( powerMgr.isValid() ) { jint levelAndFlags = QAndroidJniObject::getStaticField<jint>("android/os/PowerManager","SCREEN_DIM_WAKE_LOCK"); QAndroidJniObject tag = QAndroidJniObject::fromString( "My Tag" ); m_wakeLock = powerMgr.callObjectMethod("newWakeLock", "(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;", levelAndFlags,tag.object<jstring>()); } } }
Anu help????
-
Hi
For me it looks like an binary OR of enum values. ( like setFlags)
( PowerManager.SCREEN_DIM_WAKE_LOCK OR'ED PowerManager.ACQUIRE_CAUSES_WAKEUP )
But in java this mean some else? -
-
Hi
Syntax should be the same.
https://www.somacon.com/p125.php
For the OR part but are you talking about the actual pm.newWakeLock call or
simply the
PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP ? -
@NickV
For me something is not clear, did you already try the following or not?!jint levelAndFlags = QAndroidJniObject::getStaticField<jint>("android/os/PowerManager","SCREEN_DIM_WAKE_LOCK") | QAndroidJniObject::getStaticField<jint>("android/os/PowerManager","ACQUIRE_CAUSES_WAKEUP");