July 2018
Intermediate to advanced
266 pages
7h 11m
English
Now it's a good time to add a call to a service. To start with something simple, we will use Java's DocumentBuilder to call an RSS feed for us. First, we will add a variable to hold the DocumentBuilderFactory below where we put the dispatcher:
private val dispatcher = newSingleThreadContext(name = "ServiceCall")private val factory = DocumentBuilderFactory.newInstance()
The second step is to create a function that will do the actual call:
private fun fetchRssHeadlines(): List<String> { val builder = factory.newDocumentBuilder() val xml = builder.parse("https://www.npr.org/rss/rss.php?id=1001") return emptyList()}
Notice how the function is, for now, returning an empty list of strings after calling the ...
Read now
Unlock full access