Code example for Vibrator

Methods: vibrate

0
        int ringerMode = mAudioManager.getRingerMode();
        mVibrator = (Vibrator) mContext
                .getSystemService(Context.VIBRATOR_SERVICE);
        if (mCallInProgress) {
            // Notify with single vibrate. 
            mVibrator.vibrate((long) 200);
        } else { 
            if (AudioManager.RINGER_MODE_NORMAL == ringerMode) {
                mAudioManager.setMode(AudioManager.MODE_RINGTONE);
                ring(uri, AudioManager.STREAM_RING);
            } else if (AudioManager.RINGER_MODE_VIBRATE == ringerMode) {
 
                // Start immediately 
                // Vibrate 400, break 200, Vibrate 400, break 1000 
                long[] pattern = { 0, 400, 200, 400, 1000 };
 
                // Vibrate until cancelled. 
                mVibrator.vibrate(pattern, 0);
            } // else RINGER_MODE_SILENT 
        } 
    }