I want to pause my program for 10 sec. I don't want sleep code. After pausing for 10 sec I want to run my further code.
Asked
Active
Viewed 46 times
-3
-
Duplicate: https://stackoverflow.com/a/9166354/7874047 – Ronak Thakkar Oct 09 '17 at 15:58
-
If you want to wait for the onset of an event, then you better use CallBack, Listener or interceptor. – tim4dev Oct 10 '17 at 00:34
2 Answers
0
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 100ms
}
}, 100);
blatantly copied and pasted from here How to call a method after a delay in Android

em_
- 2,134
- 2
- 24
- 39
-
-
Yes it won't stop the NEXT LINE OF CODE, which means you need to wrap your next lines of code in a method (or in the `run()` block) – em_ Oct 10 '17 at 14:50
0
new Handler().postDelayed(new Runnable(){
public void run(){
//your code will execute after 10 secs
}},10000);

Midhun
- 178
- 1
- 10