Skip to content Skip to sidebar Skip to footer

How To Change Incoming Call Vibration Level When Incoming Call Made?

Somehow tricky question. I am working with one app through which user can set incoming call custom ringtone and different vibration level for different contacts. I have stuck with

Solution 1:

The Android Vibrate API has only time control. There is no magnitude control in that API.

For more refer this

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

Solution 2:

If you want to make lower vibration you need to create a pattern with blankspaces in the middle.

Use constants like:

int dot = 200;      
int short_gap = 200;    // Length of Gap 

and then define array and pattern:

long[] pattern = {
    0,  // Start immediately
    dot, short_gap };

then you can call:

v.vibrate(pattern, x);

// x value:// 0 repeat infinite// -1 no repeat// n number of repetitions

By changing lenght of the dot and gap (or defining new ones to perform various patterns) you can modulate power of vibration.

EDIT1: Here is my VibrationConstants.java

publicclassVibrationConstants {                         

    privatestaticint p = 5; // five millisecond of vibrationprivatestaticint s = 5; // five millisecond of break - could be more to// weaken// the vibrationprivatestaticint pp = 10; // ten millisecond of vibrationprivatestaticint ss = 10; // ten millisecond of break - could be more to// weaken// the vibrationprivatestaticint ppp = 50; // fifty millisecond of vibrationprivatestaticint sss = 50; // fifty millisecond of break - could be more to// weaken// the vibrationpublicstaticlong[] HARD_VIBRATION = { 0, ppp, sss };
    publicstaticlong[] MIDDLE_VIBRATION = { 0, pp, ss };
    publicstaticlong[] SOFT_VIBRATION_2 = { 0, p, s };

    publicstaticlong[] PATTERN_VIBRATION = { 0, 250, 200, 250, 150, 150, 75,
        150, 75, 150 }; 
}

So, when you want to call it:

v.vibrate(VibrationConstants.SOFT_VIBRATION_2, x);

// x value:// 0 repeat infinite// -1 no repeat// n number of repetitions

Try also by changing ONLY the break values if the result with same values in vibration and breaks is not accurated as you expect. This make nice effects. :)

Hope that helps, i tried to found patterns from phone brands like Google Samsung or Xperia, but i couldnt find it... so we had nice results with that patterns to simulate, but all depends of your requirements.

Im sure you will have to make some tests to reach ur target, but is not so hard.

Post a Comment for "How To Change Incoming Call Vibration Level When Incoming Call Made?"