title: NetworkOnMainThreadException when trying to run okhttp response code on UI thread
body: <p>In my Android app, I'm using <strong>AppAuth</strong> to authenticate the user with an OpenID connect endpoint, so I'm doing a bunch of asynchronous calls and when the last one returns, I'm using okhttp to get the final result and I want to show it in the UI of my activity, something like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>authService.performTokenRequest(
      authResponse.createTokenExchangeRequest()
  ) { tokenResponse: TokenResponse?, tokenException: AuthorizationException? -&gt;
      if (tokenResponse != null) {                         
          authState.performActionWithFreshTokens(authService) { accessToken, _, ex -&gt;
              if (accessToken != null) {
                  val url = ...
                  val request = ...
                  http.newCall(request).enqueue(object: Callback {
                      override fun onFailure(call: Call?, e: IOException?) {...}
                      override fun onResponse(call: Call?, response: Response?) {
                          if (response != null) {
                              this@MainActivity.runOnUiThread {
                                  textView.text = response.body()!!.string()
                              }
                          }
                      }
                  })
              }
          }
      }
  }
  </code></pre>
  <p>But then on the line when I try to update my text view, I get the following exception:</p>
  <blockquote>
  <p>android.os.NetworkOnMainThreadException</p>
  </blockquote>
  <p>And when I try to remove the <code>runOnUiThread</code>, I'm getting another exception that says: &quot;Only the original thread that created a view hierarchy can touch its views&quot;</p>
  <p>I don't get it. What should I do?</p>