[Android Studio] EmreCanAydın:
Hello everyone i try to get commands from txt file and I want to run these commands in order for a certain period of time.I can get the commands from the txt file correctly but when I want to do these commands using a countdown timer for a certain period of time, there is a problem.The problem is that I do the first command in the time that I want, but it does not execute the next commands.

My txt file:

Ileri,5,1 /n -->this command work well.mp.start() method works for 5 seconds.Commands under this command do not work.

Sol,10,1 /n -->10 is operation time 1 is The number of repetitions.

Sag,5,1 /n

Geri,10,1 /n

Button's Code:

start_btn.setOnClickListener(new View.OnClickListener() {
[MENTION=439709]override[/MENTION]

public void onClick(View v) {

String yon;

String saniye1;

String tekrar;

int i=0,j=0,c=0,d=0;

ArrayList<String> listS=new ArrayList<String>();

try {

Scanner s=new Scanner(new File("/data/data/com.example.emrecan.myapplication/files/komutlar.txt"));

while(s.hasNextLine())

{

listS.add(s.nextLine());

}

} catch (FileNotFoundException e) {

e.printStackTrace();

}

String[] line2=new String[100];

for(String str:listS)

{

String[] line=str.split(",");

line2[c]=line;

line2[c+1]=line[i+1];

line2[c+2]=line[i+2];

c=c+3;

}

String [] line3=new String[c+2];

while(d<c)

{

line3[d]=line2[d];

d=d+1;

}

d=0;

tekrar=line3[2];

int tekrar1=Integer.parseInt(tekrar);

while(d<tekrar1)

{

while(j<=c-2)

{

yon = line3[j];

saniye1 = line3[j + 1];

sure1 = Long.parseLong(saniye1);

sure1=sure1*1000;

sure1=sure1+1000;

System.out.println(yon);

System.out.println(sure1);

System.out.println(tekrar1);

e=0;

switch (yon)

{

case "Ileri":

countdowntimer=new CountDownTimer(sure1,1000) {

[MENTION=439709]override[/MENTION]

public void onTick(long millisUntilFinished) {

mp.start();

}

[MENTION=439709]override[/MENTION]

public void onFinish() {

mp.stop();

Toast.makeText(getApplicationContext(),"İleri Komutu Bitti",Toast.LENGTH_LONG).show();

}

}.start();

Toast.makeText(getApplicationContext(), "Komut Tamamlandı!", Toast.LENGTH_LONG).show();

break;

case "Sol":

countdowntimer2=new CountDownTimer(sure1,1000) {

[MENTION=439709]override[/MENTION]

public void onTick(long millisUntilFinished) {

mp2.start();

}

[MENTION=439709]override[/MENTION]

public void onFinish() {

mp2.stop();

Toast.makeText(getApplicationContext(),"Sol Komutu Bitti",Toast.LENGTH_LONG).show();

}

}.start();

Toast.makeText(getApplicationContext(), "Komut Tamamlandı!", Toast.LENGTH_LONG).show();

break;

case "Sag":

countdowntimer3=new CountDownTimer(sure1,1000) {

[MENTION=439709]override[/MENTION]

public void onTick(long millisUntilFinished) {

mp3.start();

}

[MENTION=439709]override[/MENTION]

public void onFinish() {

mp3.stop();

Toast.makeText(getApplicationContext(),"Sag Komutu Bitti",Toast.LENGTH_LONG).show();

}

}.start();

Toast.makeText(getApplicationContext(), "Komut Tamamlandı!", Toast.LENGTH_LONG).show();

break;

case "Geri":

countdowntimer4=new CountDownTimer(sure1,1000) {

[MENTION=439709]override[/MENTION]

public void onTick(long millisUntilFinished) {

mp4.start();

}

[MENTION=439709]override[/MENTION]

public void onFinish() {

mp4.stop();

Toast.makeText(getApplicationContext(),"Geri Komutu Bitti",Toast.LENGTH_LONG).show();

}

}.start();

Toast.makeText(getApplicationContext(), "Komut Tamamlandı!", Toast.LENGTH_LONG).show();

break;

default:

Toast.makeText(getApplicationContext(), "Sıkıntı var!", Toast.LENGTH_LONG).show();

break;

}

j=j+3;

}

j=0;

d=d+1;

System.out.println('A');

}

}

});

App output:

I/System.out: Ileri

6000

1

I/System.out: Sol

11000

1

I/System.out: Sag

6000

1

I/System.out: Geri

11000

1

I/System.out: A