大疆社区

标题: Android如何监听手柄C1.C2按键事件 [打印本页]

作者: djiuser_ws    时间: 2021-4-25
标题: Android如何监听手柄C1.C2按键事件
连接遥控器一直无法监听。是什么原因?

作者: djiuser_ws    时间: 2021-4-25
private RemoteController remoteController;
    @Override
    public void onUpdate(@NonNull HardwareState hardwareState) {
        Toast.makeText(getApplication(), "onUpdate", Toast.LENGTH_SHORT).show();
        remoteController.setHardwareStateCallback(hardwareState1 -> {
            if (hardwareState.getC1Button().isClicked()){
                Toast.makeText(getApplication(), "getC1Button", Toast.LENGTH_SHORT).show();
            }else if (hardwareState.getC2Button().isClicked()){
                Toast.makeText(getApplication(), "getC2Button", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplication(), "Button", Toast.LENGTH_SHORT).show();
            }
        });
    }
    @Over
作者: kv886    时间: 2021-4-26
djiuser_ws4-25 16:57
private RemoteController remoteController;
    @Override
    public void onUpdate(@NonNull HardwareState hardwareState) {
        Toast.makeText(getApplication(), "onUpdate", Toast.LENGTH_SHORT).show();
        remoteController.setHardwareStateCallback(hardwareState1 -> {
            if (hardwareState.getC1Button().isClicked()){
                Toast.makeText(getApplication(), "getC1Button", Toast.LENGTH_SHORT).show();
            }else if (hardwareState.getC2Button().isClicked()){
                Toast.makeText(getApplication(), "getC2Button", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplication(), "Button", Toast.LENGTH_SHORT).show();
            }
        });
    }
    @Over
可能与遥控器种类有关,你用的什么遥控器




欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2