-2

I have create method to vibrate the mobile,code is running well,but I can't vibration like a "play then stop then play". How can manage this type vibration?

code

 //@JavascriptInterface
    public void Viber(String value ) 
    {
        // Get instance of Vibrator from current Context
        Vibrator v = (Vibrator)mContext.getSystemService(mContext.VIBRATOR_SERVICE);
        if (value.equals("on")) 
        {
            // Vibrate for 300 milliseconds
            v.vibrate(6000);
        }
        else
        {
            v.cancel();
        }
    }
Zala Janaksinh
  • 2,929
  • 5
  • 32
  • 58
egydeveloper
  • 585
  • 5
  • 7
  • 27

1 Answers1

1

You have to create some pattern, for example:

   long pattern[]  = {0,300,200,500,200,600,200,800};

the first value is the time to wait until start vibration, the next is vibration duration, the third is pause and so on....

and then call:

   v.vibrate(pattern,-1);
Opiatefuchs
  • 9,800
  • 2
  • 36
  • 49
  • i had this error The method vibrate(long[], int) in the type Vibrator is not applicable for the arguments (int[], int) – egydeveloper Jun 26 '13 at 12:09