Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved android vibrationeffect

    Mobile and Embedded
    1
    2
    185
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tinashe last edited by

      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.2

      auto 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());

      T 1 Reply Last reply Reply Quote 0
      • T
        tinashe @tinashe last edited by

        @tinashe

        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);

        1 Reply Last reply Reply Quote 2
        • First post
          Last post