This section describes how to retrieve the power status using multimode phone sub-sessions.
The function should return the battery power level status.
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; }
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.