Android - 拨打 phone 电话

Android - Make a phone call

我正在尝试使用 Titanium Appcelerator 与 Android 进行 phone 调用,我想知道该怎么做

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

但是当然还有其他事情我需要做。
提前致谢

SDK 5.2.2 Appcelerator 4.5

这里是android代码:

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);

UPD:如@Masum 所述,您还需要添加权限:

<uses-permission android:name="android.permission.CALL_PHONE" />

试试这个 Appcelerator 方法:

Titanium.Platform.openURL('tel:1234567890');

如果这对您有用,请将其标记为其他人的答案。

试试这个:

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);
        }

}

并在 tiapp.xml 中添加您的清单:

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