Вопрос

I have a problem when I'm trying to add one object. Please Help!!!!

Vector BufferTotal = new Vector(); int n=1;

while (true) {
    if(AudioRecord.ERROR_INVALID_OPERATION != 0) {
        num = record.read(buffer, 0, 1024);
    }
    track.write(buffer,0, num);
    //Writes the audio data to the audio sink for playback (streaming mode), 
    //or copies audio data for later playback (static buffer mode)
    track.play();
    buffer2=buffer.clone();
    BufferTotal.add(n, buffer2.clone());
    n++;
    throw new IndexOutOfBoundsException("RecandPlay:Error en la posicion "+n+" de "+BufferTotal.size());

}

The error: java.lang.ArrayIndexOutOfBoundsException: length=0; index=1

Это было полезно?

Решение 2

I have replaced BufferTotal.add(int,byte[]) for BufferTotal.add(byte[]) and the application goes on correctly.

Другие советы

BufferTotal.add(n, buffer2.clone());

This line is causing error. You are trying to add element directly at index 1 instead of 0. Make n=0; and do it again.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top