Is there a way to call a method with a certain amount of delay?

Asked 1 years ago, Updated 1 years ago, 121 views

I'd like to call the method with a certain delay In Objective C, [self performSelector:@selector(DoSomething) withObject:nil afterDelay:5]; You do it like this.

What do I do on Android?

public void DoSomething()
{
     //do something here
}

If there's a method like this, I'd like to page this in five seconds.

java android handler delay

2022-09-21 16:51

1 Answers

I think there's a way to use a handler.

final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
  @Override
  public void run() {
         //Milisecond action desired to delay 
  }
}, milliseconds that you want to delay);


2022-09-21 16:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.