3

我试图有几个按钮在按下时提供几种不同的振动器嗡嗡声类型。我可以用“变量”日喂食。振动器仅在短时间内振动 3 次,然后播放祝酒词,然后停止。它没有达到 case:1 上的 16 种振动模式。

我有一个开关,因为我还有 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;

    }
}
4

0 回答 0