what i'm trying to do is while loop with delay of 15 seconds and inside the loop i want to execute volley request .. the loop is working but with no delay
this is my code : (client2 is the volley request method )
new Thread(new Runnable() {@Override
public void run() {
while (h < taxiidlist.size() && assined == false && requested == true) {
handler2.post(new Runnable() {@Override
public void run() {
client2(user.id, taxiidlist.get(h));
h++;
}
});
try {
Thread.sleep(15000);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
I don't see why the code isn't working. One possible issue might be that you have forgotten to invoke
run()
within thehandler.post()
where your inner Runnable instance is being passed.Try with this sample code (loop executed just once) and see if you can spot the issue in yours.
Hope this helps :)