title: Why must "Dispatchers.Main" be added to the root job of an implementation of an Activitys CoroutineScope?
body: <pre><code>abstract class ScopedAppActivity: AppCompatActivity(), CoroutineScope {
      protected lateinit var job: Job
      override val coroutineContext: CoroutineContext 
          get() = job + Dispatchers.Main
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          job = Job()
  
          launch(Dispatchers.Main) {
              try {
                  delay(Long.MAX_VALUE)
              } catch (e: Exception) {
                  // e will be a JobCancellationException if the activty is destroyed
              }
          }
      }
  
      override fun onDestroy() {
          super.onDestroy()
          job.cancel()
      } 
  }
  </code></pre>
  
  <p>This example is copied from the <a href="https://github.com/Kotlin/kotlinx.coroutines/blob/master/ui/coroutines-guide-ui.md#structured-concurrency-lifecycle-and-coroutine-parent-child-hierarchy" rel="nofollow noreferrer">coroutine guide</a> and extended by the <code>launch(Dispatchers.Main)</code> coroutine. I don't understand why <code>+ Dispatchers.Main</code> in line 4 is needed. If I remove this part the <code>launch</code> coroutine will be cancelled anyways if the Activity is destroyed. So what is the reason for <code>Dispatchers.Main</code>? Why is <code>Dispatchers.IO</code> not added, too?</p>