Pergunta

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();
        }
    }
Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top