android vibrationeffect
-
can someone please assist me
my app is crashing
i am and using android OS 8.1
jdk1.8.0_251
Android settings are OK. (SDK Version: 26.1.1, NDK Bundle Version: 21.1.6352462)
felgo sdk 3.5.0
qt 5.14.2auto vibroString = QAndroidJniObject::fromString("vibrator");
auto activity = QtAndroid::androidActivity();
auto appctx = activity.callObjectMethod("getApplicationContext","()Landroid/content/Context;");
auto vibratorService = appctx.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", vibroString.object());
auto vibrationEffect = QAndroidJniObject::callStaticObjectMethod("android/os/VibrationEffect","createOneShot",
"(JI)Landroid/os/VibrationEffect;", 1000, 1);
vibratorService.callMethod<void>("vibrate", "(Landroid/os/VibrationEffect;)V", vibrationEffect.object()); -
i found where i had done it wrong
Wrong way :auto vibrationEffect = QAndroidJniObject::callStaticObjectMethod("android/os/VibrationEffect","createOneShot",
"(JI)Landroid/os/VibrationEffect;", 1000, 1);Correct way:
jlong duration = 1000;
jint amplitude = 1;
auto vibration_effect = QAndroidJniObject::callStaticObjectMethod("android/os/VibrationEffect", "createOneShot", "(JI)Landroid/os/VibrationEffect;", duration, amplitude);