-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Kotlin Programming Cookbook
By :
In this recipe, we will see how to send an email using Anko's wrapper. Sending an email is very useful as almost all apps provide a method of contact. So let's get started!
I'll be using Android Studio for coding purposes. You need to include Anko library in your build.gradle file. Just add these lines and you are good to go:
compile "org.jetbrains.anko:anko-commons:$anko_version"You can also clone the repository at gitlab.com/aanandshekharroy/Anko-examples and switch to the 3-intent-actions branch to get the source code.
We will use the email function provided by Anko library that takes three parameters, out of which only one is mandatory:
email("[email protected]","Subject","Text")You can remove the subject and text if you don't want prefilled text in the email.
Let's take a look at its implementation:
fun Context.email(email: String, subject: String = "", text: String = ""): Boolean {
val intent = Intent(Intent.ACTION_SENDTO...
Change the font size
Change margin width
Change background colour