次のスニペットを使用して電話を特定のパターンで振動させていますが、ArrayIndexOutOfBoundsExceptionがスローされます。
vibrator.vibrate(new long[] { selectedDuration, CONSTANT_DELAY }, REPEAT);
しかし
vibrator.vibrate(VIBRATE_DURATION);
正常に動作します。ポインタはありますか?
ドキュメントは言う:
繰り返したい場合は、繰り返しを開始するパターンにインデックスを渡します。
あなたの場合、REPEATは0または1にしか許可されないことを意味します。
これは実装です:
public void vibrate(long[] pattern, int repeat)
{
// catch this here because the server will do nothing. pattern may
// not be null, let that be checked, because the server will drop it
// anyway
if (repeat < pattern.length) {
try {
mService.vibratePattern(pattern, repeat, mToken);
} catch (RemoteException e) {
}
} else {
throw new ArrayIndexOutOfBoundsException();
}
}