Controlling the intensity of vibration in Android phones? Is it possible?

I am developing a game. In which I want to set different vibration intensities for different events. I just want to know if the intensity and duration of the vibration can really be controlled. Any tips or links can be very helpful. Thanks in advance.

+7
java android
source share
3 answers

I think it depends on what you mean by stress. You can control the pattern and the length of the vibration, but I don’t think you can make it vibrate “stronger”.

http://developer.android.com/reference/android/os/Vibrator.html

+9
source share

I did a simple trick to somehow reduce the intensity of the vibration. My idea is to alternate vibration intervals with quiet intervals. If you have one millisecond of vibration, and then one second of silence, etc., It seems to be one constant vibration, but weaker than usual. You can try to increase the intervals of silence to make the vibration even weaker. Here is a sample code:

int strong_vibration = 30; //vibrate with a full power for 30 secs int interval = 1000; int dot = 1; //one millisecond of vibration int short_gap = 1; //one millisecond of break - could be more to weaken the vibration long[] pattern = { 0, // Start immediately strong_vibration, interval, // 15 vibrations and 15 gaps = 30millis dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, dot, short_gap, //yeah I know it doesn't look good, but it just an example. you can write some code to generate such pattern. }; 
+9
source share

PWM can be used to create a vibration diagram with different pulse widths, resulting in a lower average voltage to the vibrator motor (and therefore a weaker vibration output).

I posted a simple proof of conceptual method here . This method will generate a template with a given intensity and duration. The transition in this method is not entirely linear, so I published generosity in order to hope to get some alternative suggestions. Will be updated when I have an even better algorithm.

+2
source share

All Articles