第三版中如何获取Cell ID
hamishwillee
(Talk | contribs) m (Hamishwillee - Add translation information to ArticleMetaData) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot update of Template:ArticleMetaData) |
||
| Line 13: | Line 13: | ||
|id= <!-- Article Id (Knowledge base articles only) --> | |id= <!-- Article Id (Knowledge base articles only) --> | ||
|language=Lang-Chinese | |language=Lang-Chinese | ||
| − | |translated-by= | + | |translated-by=[[User:Hoolee]] |
|translated-from-title=Find Out Cell ID in 3rd Edition | |translated-from-title=Find Out Cell ID in 3rd Edition | ||
| − | |translated-from-id= <!-- | + | |translated-from-id=62051 <!-- automated guess --> |
|review-by=<!-- After re-review: [[User:username]] --> | |review-by=<!-- After re-review: [[User:username]] --> | ||
|review-timestamp= <!-- After re-review: YYYYMMDD --> | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| Line 21: | Line 21: | ||
|update-timestamp= <!-- After significant update: YYYYMMDD --> | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
|creationdate=20090930 | |creationdate=20090930 | ||
| − | |author=[[User: | + | |author=[[User:Feenix]] |
}} | }} | ||
| Line 180: | Line 180: | ||
Get to know more about this please refer this example: DevInfo_3.x. Please check my comments below for more clarity. EDIT: Changed the article name (previously it was Get the IMEI of a 3.x device) and added a more elaborated and extended example.</toggledisplay> | Get to know more about this please refer this example: DevInfo_3.x. Please check my comments below for more clarity. EDIT: Changed the article name (previously it was Get the IMEI of a 3.x device) and added a more elaborated and extended example.</toggledisplay> | ||
| + | <!-- Translation --> [[en:Find Out Cell ID in 3rd Edition]] | ||
Latest revision as of 07:47, 22 December 2011
文章信息
当了找出S60第三版手机当前的cell ID,程序必须要有Symbian签名。因为需要有ReadDeviceData能力。程序员必须使用active object因为这个调用要异步处理。下面是一个获取cell id的示例。
需要的头文件:
#include<etel3rdparty.h>所需链接库:
LIBRARY etel3rdparty.lib所需能力:
Capability ReadDeviceData
NetworkInfo.h
#ifndef __NETWORKINFO_H__
#define __NETWORKINFO_H__
#include <etel3rdparty.h> // CTelephony
// Observer interface
class MNetworkInfoObserver
{
public:
virtual void NetworkInfoRetrievedL(
const CTelephony::TNetworkInfoV1& aNetworkInfo) = 0;
virtual void HandleNetworkInfoError(TInt aError) = 0;
};
// Active object to get network info
class CNetworkInfo : public CActive
{
public:
static CNetworkInfo* NewL();
~CNetworkInfo();
void GetNetworkInfoL(MNetworkInfoObserver* aObserver);
protected:
// from CActive
void RunL();
TInt RunError(TInt aError);
void DoCancel();
private:
CNetworkInfo();
void ConstructL();
private:
CTelephony* iTelephony;
CTelephony::TNetworkInfoV1 iNwInfo;
CTelephony::TNetworkInfoV1Pckg iNwInfoPckg;
MNetworkInfoObserver* iObserver;
};
#endif // __NETWORKINFO_H__
NetworkInfo.cpp
#include "NetworkInfo.h"
CNetworkInfo::CNetworkInfo()
: CActive(EPriorityStandard),
iNwInfoPckg(iNwInfo)
{
CActiveScheduler::Add(this);
}
CNetworkInfo* CNetworkInfo::NewL()
{
CNetworkInfo* self = new (ELeave) CNetworkInfo;
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
void CNetworkInfo::ConstructL()
{
iTelephony = CTelephony::NewL();
}
CNetworkInfo::~CNetworkInfo()
{
Cancel();
delete iTelephony;
}
// This function is used by our class' users to start getting network info.
void CNetworkInfo::GetNetworkInfoL(MNetworkInfoObserver* aObserver)
{
__ASSERT_ALWAYS(!IsActive(), User::Leave(KErrInUse));
iObserver = aObserver;
// Start async call to receive current network information
iTelephony->GetCurrentNetworkInfo(iStatus, iNwInfoPckg);
SetActive();
}
void CNetworkInfo::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
}
void CNetworkInfo::RunL()
{
User::LeaveIfError(iStatus.Int());
// Request completed successfully.
// Now we can notify our observer.
if(iObserver)
{
iObserver->NetworkInfoRetrievedL(iNwInfoPckg());
}
}
TInt CNetworkInfo::RunError(TInt aError)
{
// There was an error retrieving current network info.
// Let's inform our observer about the error so that it can analyze it
// and try to recover.
if(iObserver)
{
iObserver->HandleNetworkInfoError(aError);
}
return KErrNone;
}
相关链接
外部链接
- Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices (Blog no longer available, content reproduced below:)

