I use the Imei-Function, which get the imei synchronously.
This is the cpp-file:
Code:
#include "SMSExampleValidate.h"
void CGetImei::GetIMEI(TDes& aIMEI)
{
CGetImei* self= new (ELeave) CGetImei(aIMEI);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::PopAndDestroy(self);
}
void CGetImei::ConstructL()
{
//if( iStatus =! KRequestPending )
//{
iTelephony = CTelephony::NewL();
CActiveScheduler::Add(this);
CTelephony::TPhoneIdV1Pckg iPhoneIdV1Pckg(iPhoneIdV1);
iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
SetActive();
CActiveScheduler::Start();
//}
}
CGetImei:: CGetImei(TDes& imei): CActive(EPriorityStandard),IMEI(imei)
{
//default constructor
}
CGetImei::~CGetImei()
{
delete iTelephony;
iTelephony = NULL;
Cancel();
}
void CGetImei::RunL()
{
if(iStatus==KErrNone)
{
IMEI= iPhoneIdV1.iSerialNumber;
CActiveScheduler::Stop();
}
}
void CGetImei::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
}
I think my code is right, because I get it from the Wiki and at other places in my program it works fine. Only in the ConstructL() from the UI it doesn`t work. I suppose that something is wrong with other active functions. I tested under the above ConstructL() the if-loop with KRequestPending. With the loop my program starts, but didn`t read the IMEI.
I don´t know, what I can further do?
Have you some ideas?