diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-F85B6D62-AD3B-5D18-990C-0884BF834EA1.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-F85B6D62-AD3B-5D18-990C-0884BF834EA1.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,26 @@ + + + + + +Phone Power Status TutorialThis section describes how to retrieve the power status using multimode phone sub-sessions. Test if the power information can be obtained using RMobilePhone::GetBatteryCaps(). Power information capabilities are described in an RMobilePhone::TMobilePhoneBatteryCaps. Get the power information using RMobilePhone::GetBatteryInfo(). Power status and charge level is returned in an RMobilePhone::TMobilePhoneBatteryInfoV1 object. Use RMobilePhone::NotifyBatteryInfoChange() to get the notification of any changes to the power information.

The function should return the battery power level status.

Power status example

The following code checks if the power information can be obtained, and if so, gets the charge level in a percentage value of the battery, if the phone is currently being powered by batteries.

The code assumes iMobilePhone is an RMobilePhone object.

TUint32 batteryCaps; +User::LeaveIfError(iMobilePhone.GetBatteryCaps(batteryCaps)); + +TInt charge = -1; +if (batteryCaps & RMobilePhone::KCapsGetBatteryInfo) + { + RMobilePhone::TMobilePhoneBatteryInfoV1 mobilePhoneBatteryInfo; + TRequestStatus status; + iMobilePhone.GetBatteryInfo(status, mobilePhoneBatteryInfo); + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); + if (mobilePhoneBatteryInfo.iStatus == RMobilePhone::EPoweredByBattery) + charge = mobilePhoneBatteryInfo.iChargeLevel; + } +
\ No newline at end of file