怎么监听来电和接听

如何监听来电和接听
如何监听来电和接听?

------解决方案--------------------
CTelephony::TCallStatusV1
CTelephony::TCallStatusV1Pckg
CTelephony
CTelephony::TNotificationEvent
------解决方案--------------------
up, never do that before
------解决方案--------------------
http://www.devdiv.net/viewthread.php?tid=2618&extra=page%3D1这个是短信的,电话也是一样只是要用CTelephony::TCallStatusV1 
CTelephony::TCallStatusV1Pckg 这两个做。
------解决方案--------------------
学习了~
------解决方案--------------------
Symbian 3rd中如何要监控来电,接听和挂断?3rd中我们一般需使用 CTelephony::NotifyChange来判定来电的状态:来电,接听和挂断等.

主要代码如下:

CTelWatcher* CTelWatcher::NewL()
{
 CTelWatcher* self = new (ELeave) CTelWatcher();
 CleanupStack::PushL(self);
 self->ConstructL();
 CleanupStack::Pop();
 return self;
}

CTelWatcher::~CTelWatcher()
{
 Cancel();

 if (iTelephony)
 {
delete iTelephony;
iTelephony = NULL;
 }
}
CTelWatcher::CTelWatcher():CActive(EPriorityStandard),iState(EPhoneRing),iCurrentStatusPckg(iCurrentStatus)
{
 iCurrentStatus.iStatus = CTelephony::EStatusUnknown;
}

void CTelWatcher::ConstructL()
{
 iTelephony = CTelephony::NewL();
 CActiveScheduler::Add(this);
}

void CTelWatcher::StartListening()
{
 Cancel();

 CAknInformationNote* iNote = new (ELeave) CAknInformationNote;
 iNote->ExecuteLD(_L("WO WO"));

iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iCurrentStatusPckg);
 SetActive();
}

void CTelWatcher::RunL()
{
 if (iStatus != KErrNone) return;
  
 switch(iCurrentStatus.iStatus)
 {
 case CTelephony::EStatusRinging: //来电
{
iState = EPhoneRing;
GetPhoneNumber(iPhoneNumber);
}
break;
 case CTelephony::EStatusAnswering://接听
{
iState = EPhoneAnswering;
CAknInformationNote* note = new (ELeave) CAknInformationNote;
note->ExecuteLD(_L("EPhoneAnswering"));
}
break;
 case CTelephony::EStatusIdle://挂断
{
iState = EPhoneHangup;
CAknInformationNote* note1 = new (ELeave) CAknInformationNote;
note1->ExecuteLD(_L("EPhoneHangup"));
}
break;
 }

 //开始下一次监控
 iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iCurrentStatusPckg);
 SetActive();
}

void CTelWatcher::DoCancel()
{
 iTelephony->CancelAsync( CTelephony::EVoiceLineStatusChangeCancel );
}

//获取来电号码
void CTelWatcher::GetPhoneNumber(TDes& aPhoneNumber)
{
 CTelephony::TCallInfoV1 callInfoV1;
 CTelephony::TCallInfoV1Pckg callInfoV1Pckg(callInfoV1);

 CTelephony::TCallSelectionV1 callSelectionV1;
 CTelephony::TCallSelectionV1Pckg callSelectionV1Pckg(callSelectionV1);

 CTelephony::TRemotePartyInfoV1 remotePartyInfoV1;
 CTelephony::TRemotePartyInfoV1Pckg remotePartyInfoV1Pckg(remotePartyInfoV1);

 callSelectionV1.iLine = CTelephony::EVoiceLine;
 callSelectionV1.iSelect = CTelephony::EInProgressCall;

 User::LeaveIfError(iTelephony->GetCallInfo(callSelectionV1Pckg,callInfoV1Pckg, remotePartyInfoV1Pckg));
 aPhoneNumber.Copy(remotePartyInfoV1Pckg().iRemoteNumber.iTelNumber);
}
------解决方案--------------------