title: How to send Media player progress from service to Activity?
body: <p>I'm trying to communicate between service and activity first I used timer task for this purpose. It worked well but the problem was media player was taking some delay to start and timer task was not giving enough delay and app was crashing. this is how I used timer task</p>
  <pre><code> timer.schedule(object : TimerTask() {
                  @RequiresApi(Build.VERSION_CODES.O)
                  override fun run() {
                      val intent = Intent(SONG_INTENT)
                      intent.putExtra(SONG_KEY, PROGRESS_BROADCAST)
                      intent.putExtra(CURRENT_PROGRESS, mediaPlayer?.currentPosition)
                      intent.putExtra(MAX_PROGRESS, mediaPlayer?.duration)
                      LocalBroadcastManager.getInstance(this@AudioPlayerService).sendBroadcast(intent)
                  }
      
              }, 0, 1000)
  </code></pre>
  <p>to giver extra delay to media player I used handler but it's not being triggered nor sending any updates. This is how I'm using handler</p>
  <pre><code>this.run {
              object : Runnable {
                  override fun run() {
                      val intent = Intent(SONG_INTENT)
                      intent.putExtra(SONG_KEY, PROGRESS_BROADCAST)
                      intent.putExtra(CURRENT_PROGRESS, mediaPlayer!!.currentPosition)
                      intent.putExtra(MAX_PROGRESS, mediaPlayer!!.duration)
                      LocalBroadcastManager.getInstance(this@AudioPlayerService).sendBroadcast(intent)
                      handler.postDelayed(this, 1000)
                  }
              }
          }
  </code></pre>