Function call doesn`t work in ConstructL() but at other places it works fine, why?
Hi, I wrote a programm, which should get the IMEI at startup. I implement the IMEI-program from the WIKI.
When I call the IMEI-function in the UI-constructor my program give me on a device the error message: [B]Program closed[/B].
On the 3rd edition emulator the program works fine and it works also fine at devices with 2nd edition sdk. Only at devices with 3rd edition it doesn`t work.
I use a developer certificate with all available capabilities.
Have anyone some suggestions or an explanation? I`m really confused, why it doesn`t work in the constructL() at 3rd edition.
Re: Function call doesn`t work in ConstructL() but at other places it works fine, why?
There could be several things.. try posting a snippet, and let us know the specific error (panic) you're getting. Search the forum for explanations to achieve this.
Re: Function call doesn`t work in ConstructL() but at other places it works fine, why?
BTW, which IMEI reading code are you using ?
As far as know the CTelephony does not work with 2nd edition (or maybe I have never tried), but has worked just fine with me when constructed in Appui's ConctructL function.
yucca
Re: Function call doesn`t work in ConstructL() but at other places it works fine, why
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);
}[/CODE]
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?
Re: Function call doesn`t work in ConstructL() but at other places it works fine, why
Basically, if you would just take the code as it is given in the Wiki it would work. I personally wrote that and tested it, and it doesn't re-assemble your code really...Thus make it easy for your self and copy paste the code from the Wiki without modifications....
yucca