Android振动器带开关

时间:2014-07-21 01:54:38

标签: android switch-statement android-vibration

我正在尝试使用几个按钮在按下时提供几种不同的振动器蜂鸣声类型。我可以在变量“day with with。进给。振动器只会很快振动三次,然后播放吐司然后停止。它没有达到16种振动模式:1。

我有一个开关,因为我还有26个模式组可以放下。

public void vibratorCheckerTester(int day)
{
    // Get instance of Vibrator from current Context
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] startpattern = {0, 200, 200};
    long[] pattern1 = {0, 500, 1000};//sleep one minute
    long[] pattern2 = {0, 500, 3000}; //sleep 1.5
    if(!v.hasVibrator())
    {
        Toast.makeText(daybuzzer.this,
        "You need to have a vibrator on your phone for this app to work.",      Toast.LENGTH_LONG).show();
    }

    // Start without a delay
    // Vibrate for 100 milliseconds
    // Sleep for 1000 milliseconds
    Toast.makeText(daybuzzer.this,
            "Start Running.", Toast.LENGTH_LONG).show();
    v.vibrate(startpattern, -1);
    v.vibrate(startpattern, -1);
    v.vibrate(startpattern, -1);


    switch(day){
        case 1:  v.vibrate(pattern1, -1); //1 min, 1.5 min, x8
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(pattern1, -1);
                v.vibrate(pattern2, -1);
                v.vibrate(startpattern, -1);
                v.vibrate(startpattern, -1);
                v.vibrate(startpattern, -1);
                break;

    }
}

0 个答案:

没有答案