DJI SDK中的新DJIKeyManager

时间:2017-05-03 23:23:02

标签: dji-sdk

在SDK 4.0中,引入了DJIKeyManager,我想知道何时以及如何使用它。

例如,函数

let batteryLevelKey = DJIBatteryKey(param: DJIBatteryParamChargeRemainingInPercent)

keyManager.startListeningForChanges(on: batteryLevelKey!, withListener: self, andUpdate: .... 
DJIKeyManager提供的

看起来与

相同
battery(_ battery: DJIBattery, didUpdate batteryState: DJIBatteryState) 

1 个答案:

答案 0 :(得分:2)

你喜欢那样

final BatteryKey batterLevelKey = BatteryKey.create(BatteryKey.CHARGE_REMAINING_IN_PERCENT);
    DJISDKManager.getInstance().getKeyManager().addListener(batterLevelKey, new KeyListener() {
        @Override
        public void onValueChange(@Nullable Object o, @Nullable Object o1) {
            int remainingChargeInPercentage = (int) o1;
            Log.d("remainingChargeInPercentage", remainingChargeInPercentage + "");
        }
    });