diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-79CFCC01-7418-5ECA-AF65-1DCAD97AA7A6.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-79CFCC01-7418-5ECA-AF65-1DCAD97AA7A6.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,62 @@ + + + + + +Battery Information TutorialThis tutorial describes the steps to retrieve the battery information from the device. create a new instance of CTelephony with active objects use CTelephony::GetBatteryInfo() to get the battery information the function returns the information in CTelephony::TBatteryInfoV1 The result contains the battery charge level and the battery status. use CTelephony::EGetBatteryInfoCancel to cancel the asynchronous function use CTelephony::EBatteryInfoChange to get the notification of any changes to the battery information pass the enumeration CTelephony::EBatteryInfoChangeCancel to cancel the notification request. Battery information example #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); + } \ No newline at end of file