Current location - Quotes Website - Signature design - How to get a mobile phone number
How to get a mobile phone number
In order to find out the current cell ID of S60 3rd edition mobile phone, the program must be signed by Symbian. Because you need the ability of ReadDeviceData. Programmers must use active objects because this call will be handled asynchronously. The following is an example of getting a cell id.

Required header file:

# include & ltetel3rdparty.h & gt

Required link library:

Etel3rdparty.lib

Required capacity:

Ability to read device data

Network information. h

#ifndef __NETWORKINFO_H__

#define __NETWORKINFO_H__

# include & ltetel3rdparty.h & gt// CTelephony

//Observer interface

MNetworkInfoObserver class

{

Public:

Virtual void NetworkInfoRetrievedL (

tnetworkinfov 1 & amp; aNetworkInfo)= 0;

Virtual VoidHandleNetworkInfoError (tinta error) = 0;

};

//Active object for obtaining network information

Network-like information: public activities

{

Public:

Static CNetworkinfo * newl ();

~ CNetworkInfo();

void GetNetworkInfoL(MNetworkInfoObserver * aObserver);

Protected:

//from CActive

void RunL();

TInt run error(TInt a error);

void DoCancel();

Private:

CNetworkInfo();

void construct 1();

Private:

CTelephony * iTelephony

CTelephony::tnetworkinfov 1 in info;

CTelephony::tnetworkinfov 1 pckg in infopckg;

MNetworkInfoObserver * io bserver;

};

#endif // __NETWORKINFO_H__

netinfo

# contains "NetworkInfo.h"

CNetworkInfo::CNetworkInfo()

:CActive(EPriorityStandard),

iNwInfoPckg(iNwInfo)

{

cactive scheduler::Add(this);

}

CNetworkInfo * CNetworkInfo::NewL()

{

CNetworkInfo * self = new(e leave)CNetworkInfo;

CleanupStack::PushL(self);

self->; construct l();

clean upstack::Pop();

Return to self;

}

void CNetworkInfo::ConstructL()

{

itele phony = CTelephony::NewL();

}

CNetworkInfo::~CNetworkInfo()

{

cancel();

Delete iTelephony

}

//This function is used by users of our class to start obtaining network information.

void CNetworkInfo::GetNetworkInfoL(MNetworkInfoObserver * AOB server)

{

__ASSERT_ALWAYS(! IsActive(),User::Leave(KErrInUse));

iObserver = aObserver

//Start asynchronous call to receive current network information.

iTelephony-& gt; GetCurrentNetworkInfo(iStatus,iNwInfoPckg);

set active();

}

void CNetworkInfo::DoCancel()

{

iTelephony-& gt; cancel async(CTelephony::EGetCurrentNetworkInfoCancel);

}

void CNetworkInfo::RunL()

{

User::LeaveIfError(iStatus。 int());

//The request completed successfully.

//Now we can inform our observers.

if(iObserver)

{

iob server-& gt; NetworkInfoRetrievedL(iNwInfoPckg());

}

}

TInt CNetworkInfo::run error(TInt aError)

{

//An error occurred while retrieving the current network information.

//Let's inform our observer of this error so that it can analyze it.

//and try to recover.

if(iObserver)

{

iob server-& gt; HandleNetworkInfoError(a error);

}

Return KErrNone

}