Juan Carlos Salinas Ojeda Juan Carlos Salinas Ojeda - 6 months ago 50
Android Question

Android - Make a phone call

I am trying to make a phone call with Android using Titanium Appcelerator and i am wondering how to do it

var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_CALL,
data: '9999999' // number to dial
});


But of course there is something else i need to do.

Thanks in advance

SDK 5.2.2
Appcelerator 4.5

Answer

try this:

function call(number){
    number = number.trim();
        var call = 'tel:' + number;
        if (OS_IOS) {
            Titanium.Platform.openURL(call);
        } else {

            var intent = Ti.Android.createIntent({
                action : Ti.Android.ACTION_CALL,
                data : call
            });
            Ti.Android.currentActivity.startActivity(intent);
        }

}

and add in your manifest in tiapp.xml:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            ...
            <uses-permission android:name="android.permission.CALL_PHONE"/>
            ...
        </manifest>
    </android>
Comments