How to make a short vibrate on Android?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
TorstenHolmer
Posts: 40
Joined: Mon Oct 28, 2013 1:23 pm
Location: Dresden, Germany

How to make a short vibrate on Android?

Post by TorstenHolmer » Wed Jun 09, 2021 8:31 am

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

Klaus
Posts: 12361
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to make a short vibrate on Android?

Post by Klaus » Wed Jun 09, 2021 9:18 am

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

TorstenHolmer
Posts: 40
Joined: Mon Oct 28, 2013 1:23 pm
Location: Dresden, Germany

Re: How to make a short vibrate on Android?

Post by TorstenHolmer » Thu Jun 10, 2021 7:47 am

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

Post Reply

Return to “Android Deployment”