enableLDM()导致异常?

时间:2018-06-17 09:04:28

标签: android dji-sdk

我在registerApp()之前调用enableLDM()来设置本地数据模式,但它不起作用并导致异常。

例外是

尝试调用虚方法' void java.util.concurrent.atomic.AtomicBoolean.set(boolean)'在null对象引用上。

这是代码的解释

    // create LDMManager
    final LDMManager _LDMManager = DJISDKManager.getInstance().getLDMManager();
    // Get reference to LDMManager OK


    // set LDMManager callback
    _LDMManager.setCallback(new LDMManager.LDMCallback() {
    @Override
    public void onLDMEnabledChange(boolean isEnabled) {
        // debug
        Toast.makeText(getApplicationContext(), "onLDMEnabledChange : isEnabled=" + isEnabled, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onLDMSupportedChange(boolean isSupported) {
        // debug
        Toast.makeText(getApplicationContext(), "onLDMSupportedChange : isSupported=" + isSupported, Toast.LENGTH_LONG).show();
    }
    });
    // Is never fired, as enableLDM does'nt work!


    // check if LDM is supported
    if (_LDMManager.isLDMSupported()) {

    // debug
    Toast.makeText(getApplicationContext(), "isLDMSupported=True", Toast.LENGTH_LONG).show();

    // debug
    Toast.makeText(getApplicationContext(), "isLDMEnabled=" + _LDMManager.isLDMEnabled(), Toast.LENGTH_LONG).show();

    // check if LDM is disabled
    if (_LDMManager.isLDMEnabled() == false) {

        // enable LDM
        DJIError _enableLDM = null;
        try
        {
            _enableLDM = _LDMManager.enableLDM();
        }
        catch (Exception ex)
        {
            // debug
            Toast.makeText(getApplicationContext(), "enableLDM.Exception : " + ex.getMessage(), Toast.LENGTH_LONG).show();
            new AlertDialog.Builder(this)
                    .setTitle("enableLDM")
                    .setMessage(ex.getMessage())
                    .show();
        }

        // check result
        if (_enableLDM == null) {

            // debug
            Toast.makeText(getApplicationContext(), "LDM was Enabled!", Toast.LENGTH_LONG).show();

            // start registration process
            startRegistrationProcess();
        }
        else {
            // debug
            Toast.makeText(getApplicationContext(), "LDM Failed to Enabled! : " + _enableLDM.getDescription(), Toast.LENGTH_LONG).show();
        }
    }
    else {
        // debug
        Toast.makeText(getApplicationContext(), "LDM Already Enabled!", Toast.LENGTH_LONG).show();

        // start registration process
        startRegistrationProcess();
    }
}
    else {
    // debug
    Toast.makeText(getApplicationContext(), "isLDMSupported=False", Toast.LENGTH_LONG).show();
}
// Says isLDMSupported=true, isLDMEnabled=false and get exception of enableLDM line.

这是一个已知错误,还是我错误地使用它?

startRegistrationProcess()执行实际的registerApp调用,只是在没有启用本地数据模式的情况下工作等。

有举例的人吗?我在CrystalSky设备上使用DSK 4.5.1,所有最新版本。

由于

杰森

0 个答案:

没有答案