androidandroid-intentkotlinanko

How to use call wrappers for Intent Anko?


I am learning Anko commons and in that, I see Intent for easy to write code to startActivity. It's working. But in that I see Anko has call wrappers for some widely used Intents:

Goal                 Solution
------------         -------------------
Make a call          makeCall(number) without tel:
Send a text          sendSMS(number, [text]) without sms:
Browse the web       browse(url)
Share some text      share(text, [subject])
Send a email         email(email, [subject], [text])

So I want to use this wrapper but don't know how. How can I use this?

Reference Like: https://github.com/Kotlin/anko/wiki/Anko-Commons-%E2%80%93-Intents#useful-intent-callers

@9spl what you have written in the answer I know that all and I have used the latest dependency but my first question was how to use makeCall(). But I got that answer how to use then I have another problem, makeCall() doesn't work. I have declared permission in manifest although it's not working. why?

sendSMS() and browse() both are working but makeCall() is not working.


Solution

  • just make sure you have added right dependency for anko in your app gradle

    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.2-3"
    
    compile "org.jetbrains.anko:anko-commons:0.10.0"
    

    Now it is so easy to use it use this as a functions of Anko Ex.if you want to make call just simply call this function like

    makeCall("PHONE_NUMBER")