Phone Power Status Tutorial

This section describes how to retrieve the power status using multimode phone sub-sessions.

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;
    }