Making a call intent using Anko
In the last recipe, we learned how to create an intent using Anko library. In subsequent recipes, we will see how to do common things like sending messages, calls, mails, and so on using intents in Anko.
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 following lines to your build.gradle file and you are good to go:
compile "org.jetbrains.anko:anko-commons:$anko_version"You can also clone the gitlab.com/aanandshekharroy/Anko-examples repository and switch to the 3-intent-actions branch to get the source code.
How to do it…
Let's follow the given steps to make a call using intents:
- Anko provides wrappers around the most common actions that can be done using intents; one of them is making calls. For this purpose, Anko provides the
makeCallfunction, which takes in the phone number you want to call:
makeCall("+9195XXXXXXXX")- The
makeCallfunction returns true if the action was successful...