×
Namespaces

Variants
Actions
(Difference between revisions)

第三版中如何获取Cell ID

From Nokia Developer Wiki
Jump to: navigation, search
hoolee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Move to correct Category:Location)
Line 1: Line 1:
 +
[[Category:Location]][[Category:Symbian C++]][[Category:Telephony]]
 
当了找出[[S60]]第三版手机当前的cell ID,程序必须要有Symbian签名。因为需要有ReadDeviceData能力。程序员必须使用[[active object]]因为这个调用要异步处理。下面是一个获取cell id的示例。
 
当了找出[[S60]]第三版手机当前的cell ID,程序必须要有Symbian签名。因为需要有ReadDeviceData能力。程序员必须使用[[active object]]因为这个调用要异步处理。下面是一个获取cell id的示例。
  
Line 151: Line 152:
  
  
[[Category:Symbian C++]][[Category:Code_Examples]][[Category:Telephony]][[Category:Location Based Services]][[Category:Lang-CN]]
+
[[Category:Code_Examples]]
 +
[[Category:Lang-CN]]

Revision as of 01:32, 18 March 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;
}


相关链接

外部链接

196 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.

×