×
Namespaces

Variants
Actions
(Difference between revisions)

第三版中如何获取Cell ID

From Nokia Developer Wiki
Jump to: navigation, search
hoolee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update of Template:ArticleMetaData)
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
[[Category:Location]][[Category:Symbian C++]][[Category:Telephony]][[Category:Lang-Chinese]][[Category:Code Snippet]]
 +
{{ArticleMetaData
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language=Lang-Chinese
 +
|translated-by=[[User:Hoolee]]
 +
|translated-from-title=Find Out Cell ID in 3rd Edition
 +
|translated-from-id=62051 <!-- automated guess -->
 +
|review-by=<!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate=20090930
 +
|author=[[User:Feenix]]
 +
}}
 +
 +
 
当了找出[[S60]]第三版手机当前的cell ID,程序必须要有Symbian签名。因为需要有ReadDeviceData能力。程序员必须使用[[active object]]因为这个调用要异步处理。下面是一个获取cell id的示例。
 
当了找出[[S60]]第三版手机当前的cell ID,程序必须要有Symbian签名。因为需要有ReadDeviceData能力。程序员必须使用[[active object]]因为这个调用要异步处理。下面是一个获取cell id的示例。
  
Line 147: Line 173:
 
== 外部链接 ==
 
== 外部链接 ==
  
* [http://blogs.forum.nokia.com/view_entry.html?id=421 DevInfo - Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices]
 
  
 +
* Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices (Blog no longer available, content reproduced below:)
 +
<toggledisplay>In this blog entry I would like to share a small utility class, which is nothing but to find the Phone/Network/Subscriber related information in a synchronous way. In Forum Nokia Technical Library there is already a tip for finding the IMEI number in synchronously, you can find it here. I've just used that approach here to find these details: Phone information: manufacturer, model and serial number (IMEI). You've to basically use the CTelephony::GetPhoneId() API to get these information. Network information: cell id, location area code, country code etc. (this can be extended, check the SDK Help of CTelephony for that). With CTelephony::GetCurrentNetworkInfo() API you can gather the network related information. Notice here you need a ReadDeviceData capability for accessing this function. Subscriber information: subscriber id (IMSI).
  
 +
The CTelephony::GetSubscriberId() API will help you retrieve this information. All the above functions are not synchronous so to make it synchronous the work-around is the use of CActiveSchedulerWait. After the call of these asynchronous and SetActive() you have to call a iActiveSchedulerWait->Start() and in your RunL() you have to check whether the iActiveSchedulerWait is already started with iActiveSchedulerWait->IsStarted() if then stop by iActiveSchedulerWait->Stop(), then fetch the information.
  
[[Category:Symbian C++]][[Category:Code_Examples]][[Category:Telephony]][[Category:Location Based Services]][[Category:Lang-CN]]
+
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

Article Metadata

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 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;
}


[edit] 相关链接

[edit] 外部链接

  • Get the IMEI, IMSI, CellId etc., synchronously on 3.x devices (Blog no longer available, content reproduced below:)
[show details]
This page was last modified on 22 December 2011, at 07:47.
163 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.

×