Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. android vibrationeffect

android vibrationeffect

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 417 Views
  • 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 Offline
    T Offline
    tinashe
    wrote on last edited by
    #1

    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
    0
    • T tinashe

      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 Offline
      T Offline
      tinashe
      wrote on last edited by
      #2

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

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved