Android Question Short Vibration not working anymore on Android 15 (Pixel 8 Pro)

Hi,

a short vibrate from 50 to 450 does not work anymore. Nothing seems to happen.
Anyway using 45000 as parameter, it vibrates like hell.

Nothing in Code was changed, so i tried to compile against current B4A/java but it also does not help.

Any ideas why it worked in past?

Dim Vibrate As PhoneVibrate
Dim const VibOnPlus As Int = 60
..
Vibrate.Vibrate(VibOnPlus)

Lib Phone 2.60 checked in Lib Manager

Seems that the function does not accept lower values anymore.
It is a simple App, it is open (foreground), vibrate should happen after button is pressed. works for higher values.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Untested code:
B4X:
Private Sub Vibrate(Milliseconds As Long, Aplitude As Int)
    Dim VibrationEffect As JavaObject
    VibrationEffect = VibrationEffect.InitializeStatic("android.os.VibrationEffect") _
        .RunMethod("createOneShot", Array(Milliseconds, Aplitude))
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim Vibrator As JavaObject = ctxt.RunMethod("getSystemService", Array("vibrator"))
    Vibrator.RunMethod("vibrate", Array(VibrationEffect))
End Sub

My guess is that the behavior will be the same but try it.

And don't forget the permission:
B4X:
AddPermission(android.permission.VIBRATE)
 
Upvote 0
Top