symbian 下面调用电话拨号的方法

本文提供了一段在Symbian S60平台中用于拨打电话的有效代码示例。该代码详细展示了如何连接电话服务器、加载设备驱动、获取电话信息并发起呼叫的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

symbian 下面调用电话拨号的方法

开发电话本应用的时候,时常会需要直接拨打对方的电话号码。
那么,如何在symbian s60平台上通过代码让自己的手机拨号呢?
下面的代码可能会帮助你的:

加入头文件:
#include <etel.h>            // for dial operatons
在mmp文件中需要加入:
LIBRARY         etel.lib        // for dial operations
TBool CMcAppUi::dialTel(TDesC & telNum) {
        _LIT(KPHONE_DRV, "phonetsy.tsy") ;
        //Create a connection to the tel server
        RTelServer server;
        CleanupClosePushL(server);
        User::LeaveIfError(server.Connect());
        
        //Load in the phone device driver
        User::LeaveIfError(server.LoadPhoneModule(KPHONE_DRV));
        
        //Find the number of phones available from the tel server
        TInt numberPhones;
        User::LeaveIfError(server.EnumeratePhones(numberPhones));
        
        //Check there are available phones
        if (numberPhones < 1)        {
                User::Leave(KErrNotFound);
        }
        
        //Get info about the first available phone
        RTelServer::TPhoneInfo info;
        User::LeaveIfError(server.GetPhoneInfo(0, info));
        
        //Use this info to open a connection to the phone, the phone is identified by its name
        RPhone phone;
        CleanupClosePushL(phone);
        User::LeaveIfError(phone.Open(server, info.iName));
        
        //Get info about the first line from the phone
        RPhone::TLineInfo lineInfo;
        User::LeaveIfError(phone.GetLineInfo(0, lineInfo));
        
        //Use this to open a line
        RLine line;
        CleanupClosePushL(line);
        User::LeaveIfError(line.Open(phone, lineInfo.iName));
        
        //Open a new call on this line
        TBuf <100> newCallName;
        RCall call;
        CleanupClosePushL(call);
        User::LeaveIfError(call.OpenNewCall(line, newCallName));
        
        //newCallName will now contain the name of the call
        User::LeaveIfError(call.Dial(telNum));
        
        //Close the phone, line and call connections and remove them from the cleanup stack
        //NOTE: This does not hang up the call
        CleanupStack::PopAndDestroy(3);//phone, line, call
        
        //Unload the phone device driver
        User::LeaveIfError(server.UnloadPhoneModule(KPHONE_DRV));
        
        //Close the connection to the tel server and remove it from the cleanup stack
        CleanupStack::PopAndDestroy(&server);
        return ETrue ;
}
这段代码很好用的,在多款s60真机上测试过
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值