Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

从CTelephony获取网络名

From Wiki
Jump to: navigation, search
Article Metadata

代码示例
文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑

Needs-update.png本文需要更新: 如果您发现这篇文章有用,请修复下面的问题,然后从文章中删除 {{ArticleNeedsUpdate}} 模板,以消除此警告。

原因: hamishwillee (21 Dec 2011)
Needs to be merged with near-duplicate topic 使用CTelephony获取网络名

CNwNameCheck类描绘了如何使用CTelephony API获取当前网络名,注意这个例子仅为S60第三版手机所用,无法工作在老版本上。

要使用实例,则需要完成回调接口实现,并在构造CNwNameCheck实例时将类传递进去,这样回调函数就可以获得当前网络名了。

GetNetWorkName.cpp

CNwNameCheck::~CNwNameCheck()
{
Cancel();
delete iTelephony;
}
 
void CNwNameCheck::ConstructL(void)
{
iTelephony = CTelephony::NewL();
iTelephony->GetCurrentNetworkName(iStatus, iIdV1Pkg);
SetActive();
}
 
CNwNameCheck::CNwNameCheck(MNwNameObserver& aObserver)
: CActive(EPriorityNormal),iObserver(aObserver),iIdV1Pkg(iIdV1)
{
CActiveScheduler::Add(this);
}
 
void CNwNameCheck::RunL()
{
iObserver.NetworkNameL(iIdV1.iNetworkName);
 
}
 
void CNwNameCheck::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkNameCancel);
}


GetNetWorkName.h

#include <Etel3rdParty.h>
 
 
class MNwNameObserver
{
public:
virtual void NetworkNameL(const TDesC& aNwName) = 0;
};
 
 
class CNwNameCheck : public CActive
{
public:
CNwNameCheck(MNwNameObserver& aObserver);
void ConstructL(void);
~CNwNameCheck();
private:
void RunL();
void DoCancel();
private:
MNwNameObserver& iObserver;
CTelephony* iTelephony;
CTelephony::TNetworkNameV1 iIdV1;
CTelephony::TNetworkNameV1Pckg iIdV1Pkg;
};

示例

This page was last modified on 22 December 2011, at 04:47.
139 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.

×