title: How to delay the execution of code without using a new thread in Android
body: <p>In Eclipse, I found that using a TimeLine and a KeyFrame I can delay the execution of code, for example, to wait 4 seconds before playing a media I used this code:</p>
  
  <pre><code>Timeline timeline = new Timeline();
  KeyFrame keyframe = new KeyFrame(Duration.millis(4000), DelayAnimation -&gt;
  {
      GeneralMethods PlayMusic = new GeneralMethods();
      PlayMusic.playMusic(mediaPlayer);
  });
  
  timeline.getKeyFrames().add(keyframe);
  timeline.play();
  </code></pre>
  
  <p>The previous code works fine in Eclipse and I did not need to create a new thread.</p>
  
  <p>My question is, Is there a similar way to delay the execution of code in Android?</p>
  
  <p>I found a way to delay the execution of code, but it is using a handler, that is to say, creating a new thread. I would like to delay without using a thread, is it possible?</p>