×
Namespaces

Variants
Actions
Revision as of 07:57, 22 December 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

如何判断手机连接上充电器了

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

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

可以通过CTelephony类中的GetIndicator()来获得相关信息。

  • 异步调用,我们可以通过调用CTelephony::EGetIndicatorCancel来取消它


所需链接库:

LIBRARY Etel3rdParty.lib and euser.lib


class CClientApp : public CActive
{
 
private:
CTelephony* iTelephony;
CTelephony::TIndicatorV1 iIndicatorV1;
CTelephony::TIndicatorV1Pckg iIndicatorV1Pckg;
public:
CClientApp(CTelephony* aTelephony);
void DetectCharger();
 
private:
void RunL();
void DoCancel();
};
 
CClientApp::CClientApp(CTelephony* aTelephony)
: CActive(EPriorityStandard),
iTelephony(aTelephony),
iIndicatorV1Pckg(iIndicatorV1)
{
//Constructor
CActiveScheduler::Add(this);
}
 
void CClientApp::DetectCharger()
{
iTelephony->GetIndicator(iStatus, iIndicatorV1Pckg);
SetActive();
}
 
void CClientApp::RunL()
{
if(iStatus==KErrNone)
{
if(iIndicatorV1.iCapabilities & CTelephony::KIndChargerConnected)
{
//We can detect when a charger is connected
if(iIndicatorV1.iIndicator & CTelephony::KIndChargerConnected)
{
//Now, charger is connected
}
else
{
//Here, charger is not connected
}
}
else
{
//Here, we do not know whether or not a charger is connected
}
}
}
 
//To cancel this asynchronous call
void CClientApp::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetIndicatorCancel);
}
This page was last modified on 22 December 2011, at 07:57.
130 page views in the last 30 days.
×