August 2017
Intermediate to advanced
440 pages
10h
English
To make proper use of the startActivity method, we need a way to pass parameters to the Activity being started (Bundle). It is possible to update the preceding implementation to support arguments like this:
startActivity<ProductActivity>("id" to 123, "extended" to true)
In the preceding example, arguments are filled using a key and value provided by pairs (defined by the inline to function). This function implementation is, however, outside of the scope of this book. We can, however, use an existing one. The Anko library (https://github.com/Kotlin/anko) already implements the startActivity method with all the required functionality. We just need to import the Appcompat-v7-commons dependency:
compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version" ...
Read now
Unlock full access