Reading IMEI in 3rd Edition
Article Metadata
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Created: symbianyucca
(20 Mar 2007)
Last edited: hamishwillee
(08 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:)


05 Sep
2009
IMEI number being unique is mostly used for licensing and billing. The example code provided in this article provides information on how to retrieve the IMEI number from your phone in 3rd Edition. Very useful and easy for any beginner to implement.
07 Sep
2009
From time to time it is necessary to use special unique value, associated with the current device (for example while generating activation key for your application). The device IMEI is a best choice in such situation.
This article demonstrates how to read the device IMEI in S60 3rd Edition. The realization is based on two idioms: active objects and observer pattern. Combination of these approaches is very popular in Symbian C++. The example of the class, demonstrated in the article is fully self-contained. You could just copy it in your own project.