试图获得相机显示名称崩溃活动页面



因为fpvwidget和fpvoverlaywidget均不携带设置,并且适用于zenmuse xt im尝试将设置活动做出我可以更改一些基本设置的地方。如果未连接Zenmuse XT,我不想启用这些设置。因此,我一直在编写一些测试代码来检查功能,并且设置活动不断崩溃,而LogCat的错误说:

java.lang.nullpointerexception:尝试调用虚拟方法 ' 对象参考

这是我的代码:

thermalColorPalletSwitch=(Switch)findViewById(R.id.thermalColorPalletSwitch);
        if(FPVApplication.getProductInstance().getCamera().getDisplayName().equals(Camera.DisplayNameXT)){
            thermalColorPalletSwitch.setEnabled(false);
        }else{
            thermalColorPalletSwitch.setEnabled(false);
        }

我也尝试了此代码,结果相同:

        thermalColorPalletSwitch=(Switch)findViewById(R.id.thermalColorPalletSwitch);
        if(FPVApplication.getProductInstance().getCamera() != null){
            if(FPVApplication.getProductInstance().getCamera().getDisplayName().equals(Camera.DisplayNameXT)){
                thermalColorPalletSwitch.setEnabled(true);
            }else{
                thermalColorPalletSwitch.setEnabled(false);
            }
        }

我不确定我在做什么错。

我还尝试了以下代码,该代码在我的Inspire 1上交换时,在Zenmuse X3和Zenmuse XT之间交换时的目的。但是,如果应用程序与远程控制器没有连接,则设置活动仍会崩溃。

thermalColorPalletSwitch=(Switch)findViewById(R.id.thermalColorPalletSwitch);
        if(FPVApplication.getProductInstance().getCamera() != null){
            if(FPVApplication.getProductInstance().getCamera().isThermalCamera()){
                thermalColorPalletSwitch.setEnabled(true);
            }else{
                thermalColorPalletSwitch.setEnabled(false);
            }
        }

我弄清楚了。因此,显然,您必须检查是否甚至在开始检查是否有有关摄像机的任何信息之前,都必须查看与DJI产品的连接。

此代码无崩溃而起作用。

 thermalColorPalletSwitch=(Switch)findViewById(R.id.thermalColorPalletSwitch);
        if(null != FPVApplication.getProductInstance() && FPVApplication.getProductInstance().isConnected()){
            if(FPVApplication.getProductInstance().getCamera().isThermalCamera()){
                thermalColorPalletSwitch.setEnabled(true);
            }else{
                thermalColorPalletSwitch.setEnabled(false);
            }
        }

最新更新