Set timer for each loop means if there are 3 items in an array and to access those we need call forloop. What I want there is when the 1st loop is running it should run up to a specific time. Then the second loop run with the given specific time to it. I already tried with the time delay with Handler but it is not working. In Handler, all loop run at once but execute after the specific time. I don't know how to set the timer for each loop.
{
"tp_id": 85,
"id": 15,
"therapy_type": 1,
"mode": 0,
"level": 5,
"duration": 7
},
{
"tp_id": 85,
"id": 16,
"therapy_type": 2,
"mode": 3,
"level": 4,
"duration": 1
},
{
"tp_id": 85,
"id": 17,
"therapy_type": 1,
"mode": 3,
"level": 4,
"duration": 1
}
I am accessing the duration value from these above arrays and want to run each loop with their specific duration. I tried with time delay but not working as I want.
for(int i=0;i<type.size();i++){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Log.e("chekkk",""+i);
}
}, duration.get(i) * 1000);
}