DJI Mobile SDK Documentation

class BatteryWidget

class BatteryWidget extends DynamicFrameLayoutWidget
Package:dji.ux.widget
Inherits From:DynamicFrameLayoutWidget
Description:

This widget is configurable to hide some of the subviews. Use the attribute "excludeView" with flags corresponding to each subview to hide. Here are all the flags:

    batteryIcon, percentage, singleVoltage, doubleVoltage

Note that multiple flags can be used simultaneously by logically OR'ing them. For example, if user wants to hide voltage subviews in the widget, it can be done by following two steps.

Define custom xmlns in its layout file:

    xmlns:custom="http://schemas.android.com/apk/res-auto"

Then, add following attribute to the BatteryWidget:

    custom:excludeView="singleVoltage|doubleVoltage"

Display:

uilib_image

Battery icon has two color states. White color indicates everything is ok. Icon will change into red color if aircraft needs to return home, land immediately, or battery connection is bad. Text shows percentage of charge remaining in battery. Text also has two color states. Green indicates the percentage is ok. Red indicates the percentage is either below or just enough for returning home or landing immediately.

Usage:

Preferred Aspect Ratio: 28:11.

Class Members:
method onBatteryPercentageChange
@MainThread
@Keep
void onBatteryPercentageChange(@IntRange(from = 0, to = 100) int percentage)
Package:dji.ux.widget
Description:

Triggers when battery percentage changes

Input Parameters:
@IntRange(from = 0, to = 100) int percentagefrom 0 - 100; 0 means empty, 100 means full.
method onBatteryConnectionStateChange
@MainThread
@Keep
void onBatteryConnectionStateChange(@Nullable ConnectionState status)
Package:dji.ux.widget
Description:

Triggers when DJIBatteryConnectionState changes

Input Parameters:
@Nullable ConnectionState statusNormal, means the battery status is good, other values mean the battery is in error state.
method onRemainingBatteryStateChange
@MainThread
@Keep
void onRemainingBatteryStateChange(@Nullable BatteryThresholdBehavior warningLevel)
Package:dji.ux.widget
Description:

Triggers when warning level of battery changes

Input Parameters:
@Nullable BatteryThresholdBehavior warningLevelNormal, means the battery energy is good. Low, means the battery energy is OK to go home. VeryLow, means the battery energy is only for landing immediately.