Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Reading IMEI in 3rd Edition

From Wiki
Jump to: navigation, search
Article Metadata
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Created: symbianyucca (20 Mar 2007)
Last edited: hamishwillee (30 May 2013)

CImeiReader example illustrates how to read IMEI (which is an identification number that is unique for each mobile phone) in 3rd Edition Symbian devices. When this code is run on emulator it gives IMEI as "0000000000000", so better to test it on real device.

Library Needed:

LIBRARY  etel3rdParty.lib


Capability required:

CAPABILITY None

NOTE: There has been some mixed information regarding the need of "ReadDeviceData" capability for reading IMEI. That capability is not required to read IMEI, but instead is needed for reading IMSI.

IMEI_Getter.cpp

#include "IMEI_Getter.h"
 
CImeiReader* CImeiReader::NewL(MImeiObserver* aObserver)
{
CImeiReader* self = NewLC(aObserver);
CleanupStack::Pop(self);
return self;
}
 
CImeiReader* CImeiReader::NewLC(MImeiObserver* aObserver)
{
CImeiReader* self = new (ELeave) CImeiReader(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
 
CImeiReader::CImeiReader(MImeiObserver* aObserver)
:CActive(EPriorityStandard), iObserver(aObserver), iIdV1Pkg(iIdV1)
{
}
 
CImeiReader::~CImeiReader()
{
Cancel();
delete iTelephony;
}
 
void CImeiReader::ConstructL(void)
{
CActiveScheduler::Add(this);
 
iTelephony = CTelephony::NewL();
iTelephony->GetPhoneId(iStatus,iIdV1Pkg);
SetActive();
}
 
void CImeiReader::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
}
 
void CImeiReader::RunL()
{
iObserver->GotIMEIL(iIdV1.iSerialNumber,iStatus.Int());
}


IMEI_Getter.h

#include <Etel3rdParty.h>
 
 
class MImeiObserver
{
public:
virtual void GotIMEIL(const TDesC& aIMEI,TInt aError) = 0;
};
 
class CImeiReader : public CActive
{
public:
static CImeiReader* NewL(MImeiObserver* aObserver);
static CImeiReader* NewLC(MImeiObserver* aObserver);
~CImeiReader();
 
protected:
void DoCancel();
void RunL();
 
private:
CImeiReader(MImeiObserver* aObserver);
void ConstructL(void);
 
private:
MImeiObserver* iObserver;
CTelephony* iTelephony;
CTelephony::TPhoneIdV1 iIdV1;
CTelephony::TPhoneIdV1Pckg iIdV1Pkg;
};

See Also

  • Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices (Blog no longer available, content reproduced below:)
[show details]
This page was last modified on 30 May 2013, at 04:35.
125 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×