Source code for an Android AsyncTask (REST client) example

I just got back into using an Android AsyncTask, and it took me a little while to re-load the concepts in my head. I used AsyncTask’s a few years ago, but haven’t used them since.

To help remember how they work, I created a little AsyncTask example project, and I’ve included all of the source code for that project here. I’ll show all of the source code for my classes and configuration files, and then explain the code at the end.

The Internet is broken (Evan Williams)

“I thought once everybody could speak freely and exchange information and ideas, the world is automatically going to be a better place,” Mr. Williams says. “I was wrong about that.”

~ Evan Williams, in a N.Y. Times article, The Internet is broken.

Processing HTTP response headers with a ScalaJ-HTTP web client

If for some reason you ever want to print out some HTTP response headers from a HEAD request when using ScalaJ-HTTP as an HTTP client, this example may help point you in the right direction:

import scalaj.http._

object TestHead extends App
    val response: HttpResponse[String] = Http("")
        .timeout(connTimeoutMs = 2000, readTimeoutMs = 5000)
    for ((k,v) <- response.headers) println(s"key:   $k\nvalue: $v\n")

I may write more about ScalaJ-HTTP in the future, but for today that’s a quick example of processing the response headers/parameters when making a HEAD request.