Sharing some text using intents in Anko
In this recipe, we will look at how to share text using Anko wrapper. Sharing text is a very common thing and Anko provides a wrapper for this action that is very easy to use. So let's get started!
Getting ready
I'll be using Android Studio for coding purposes. You need to include Anko library in your build.gradle
file. Just add the given 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.
How to do it…
In the following steps, we will see how to share text using an intent:
- Anko provides a
share
method, which takes in a string parameter, that is, the text to share and an optional parameter subject. The subject parameter can be particularly useful to share text via an email app. After all, who sends a subject for a whatsapp message, right? Let's see its implementation:
share("Hey",...