Conventions used
There are a number of text conventions used throughout this book.
Code in text
: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “runOnUIThread
will perform the displayText(text)
function on the main UI thread.”
A block of code is set as follows:
lifecycleScope.launch(Dispatchers.IO) {
val fetchedText = fetchText()
withContext(Dispatchers.Main) {
displayText(fetchedText)
}
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
private fun fetchTextWithThread() {
Thread {
// get text from network
val text = getTextFromNetwork()
runOnUiThread {
// Display on UI
displayText(text)
}
}.start()
}
Any command-line input or output is written as follows:
java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “In Android Studio, the Editor window identifies the suspending function calls in your code with a gutter icon next to the line number.”
Tips or Important Notes
Appear like this.