This tutorial describes the steps to retrieve the battery information from the device.
#include <e32base.h> #include <Etel3rdParty.h> class CClientApp : public CActive { private: CTelephony* iTelephony; CTelephony::TBatteryInfoV1 iBatteryInfoV1; CTelephony::TBatteryInfoV1Pckg iBatteryInfoV1Pckg; public: CClientApp(CTelephony* aTelephony); void SomeFunction(); private: /* These are the pure virtual methods from CActive that MUST be implemented by all active objects */ void RunL(); void DoCancel(); }; CClientApp::CClientApp(CTelephony* aTelephony) : CActive(EPriorityStandard), iTelephony(aTelephony), iBatteryInfoV1Pckg(iBatteryInfoV1) { //default constructor } void CClientApp::SomeFunction() { iTelephony->GetBatteryInfo(iStatus, iBatteryInfoV1Pckg); SetActive(); } void CClientApp::RunL() { if(iStatus==KErrNone) { CTelephony::TBatteryStatus batteryStatus = iBatteryInfoV1.iStatus; TUint chargeLevel = iBatteryInfoV1.iChargeLevel; } } void CClientApp::DoCancel() { iTelephony->CancelAsync(CTelephony::EGetBatteryInfoCancel); }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.