Page 1 of 1

How to make a short vibrate on Android?

Posted: Wed Jun 09, 2021 8:31 am
by TorstenHolmer
Hi,

instead of the mobileVibrate command, which has a standard length, I want to have a very short vibration.
There is a way to to do this in Java: https://stackoverflow.com/questions/139 ... -frequency

Code: Select all

// Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// Vibrate for 400 milliseconds
v.vibrate(400);
How can I call this command from Livecode?

Cheers,
Torsten

Re: How to make a short vibrate on Android?

Posted: Wed Jun 09, 2021 9:18 am
by Klaus
Hi Torsten,

we can only add the (number of vibrating) parameter to the -> mobilevibrate command.
For anything else you will need to create widget with LCB.


Best

Klaus

Re: How to make a short vibrate on Android?

Posted: Thu Jun 10, 2021 7:47 am
by TorstenHolmer
Hi Klaus,

your suggestion is correct. Does anybody have more specific advise about how complex it is to write this widget?

It seems to be a very simple command and I hope that the LCB code could be also simple, but I have not found any examples of a simple java command like this. In the simplest form, I would send the LCB widget a message like send "Vibrate 100" to widget "AndroidVibrator" and then the phone should vibrate 100 milliseconds.

Is there anybody who have done something similar?

Cheers,
Torsten