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.

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

From 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 04:57.
65 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.

×