This page was last modified 17:13, 16 February 2008.
Reading IMEI in 3rd edition -Synchronously
From Forum Nokia Wiki
IMEI stands for "International Mobile Equipment Identity". There is a frequent use of reading IMEI in mobile phone development. People generally use IMEI for license/full version support of an application.
IMEIApp.h
#include <e32base.h> #include <Etel3rdParty.h> class CIMEIApp : public CActive { private: void ConstructL(); CTelephony* iTelephony; CTelephony::TPhoneIdV1 iPhoneIdV1; CTelephony::TPhoneIdV1Pckg iPhoneIdV1Pckg; public: CIMEIApp(TDes& aIMEI); ~CIMEIApp(); static void GetIMEI(TDes& aIMEI); TDes& IMEI; private: /* These are the pure virtual methods from CActive that MUST be implemented by all active objects */ void RunL(); void DoCancel(); };
IMEIApp.cpp
#include "IMEIApp.h" void CIMEIApp::GetIMEI(TDes& aIMEI) { CIMEIApp* self= new (ELeave) CIMEIApp(aIMEI); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::PopAndDestroy(self); } void CIMEIApp::ConstructL() { iTelephony = CTelephony::NewL(); CActiveScheduler::Add(this); iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg); SetActive(); CActiveScheduler::Start(); } CIMEIApp:: CIMEIApp(TDes& imei): CActive(EPriorityStandard),IMEI(imei),iPhoneIdV1Pckg(iPhoneIdV1) { //default constructor } CIMEIApp::~CIMEIApp() { delete iTelephony; iTelephony = NULL; } void CIMEIApp::RunL() { if(iStatus==KErrNone) { IMEI= iPhoneIdV1.iSerialNumber; CActiveScheduler::Stop(); } } void CIMEIApp::DoCancel() { iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel); }
Now do the following steps:
1) Create a sample "Hello World" type application.
2) Put IMEIApp.h file in your application's inc folder.
3) Put IMEIApp.cpp file in your application's src folder.
4) Open .mmp file and add entry SOURCE IMEIApp.cpp.
5) Open .mmp file and add entry LIBRARY etel3rdparty.lib.
7) Now you need to include following header in your class to read IMEI:
#include "IMEIApp.h". Let's say in for e.g.: "CYrAppUi.h"
8) You can then call the static function from any of your Commands.
For ex: in your CYrAppUi.h you need to include "IMEIApp.h"
And Call it like:
case EReadIMEICommand1:
{
TBuf<25> iIMEI;
CIMEIApp::GetIMEI(iIMEI);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(iIMEI);
}You can find a working application which is built in MS 2003 IDE with Carbide.vs Support.
Here it goes: [Read IMEI]
See Also
- IMEI on Wikipedia
- Online tool to analyze IMEI
- DevInfo - Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [announce] Miso 1.91 for 2nd and 3rd edition !!! | cyke64 | Python | 17 | 2007-01-11 18:53 |
| [announce] GNUBox for 3rd ! | cyke64 | Python | 81 | 2007-11-24 16:39 |
| How to get permission the operator or manufacturer | saurio | Mobile Java General | 3 | 2008-06-16 16:34 |
| No consigo obtener el IMEI en un 6131 NFC | dlopez | Foro en Español (Spanish Forum) | 1 | 2007-11-14 12:30 |
| 请教一个SDK的问题 | mawenjie | Symbian | 5 | 2006-01-27 06:16 |
