wjc
2025-04-24 1402cca44aae4eef9509ea6051ace918e635d23f
app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -42,6 +42,7 @@
import com.hdl.sdk.link.core.connect.HDLUdpConnect;
import com.hdl.sdk.link.core.utils.QueueUtils;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
import com.umeng.commonsdk.UMConfigure;
import org.greenrobot.eventbus.EventBus;
@@ -99,8 +100,8 @@
        String language = UserConfigManage.getInstance().getCurrentAppLanguage();
        if (TextUtils.isEmpty(language)) {
            //从内存里面获取不到语言,获取当前系统的;
            String str = getResources().getConfiguration().locale.getCountry();
            if (str.equals("CN") || str.equals("TW")) {
            String str = getResources().getConfiguration().locale.getLanguage();
            if (str.equals(LocalManageUtil.zh)) {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh);
            } else {
                UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en);
@@ -170,8 +171,23 @@
        this.networkMonitoring();
        //初始化本地assets文件夹资源文件
//        this.initLocalAssetsData();
        //初始化友盟SDK
        initUMengSDK();
    }
    /**
     * 初始化友盟SDK,抓闪退日志
     * 集成教程地址:https://developer.umeng.com/docs/119267/detail/118588
     */
    private void initUMengSDK() {
        UMConfigure.preInit(this, "6801aec0bc47b67d833fd76d", "XenterraSolar");
        //appkey和channl必须保持和预初始化一致!!!
        //deviceType:设备类型,UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子
        //pushSecret:Push推送业务的secret
        UMConfigure.init(this, "6801aec0bc47b67d833fd76d", "XenterraSolar", UMConfigure.DEVICE_TYPE_PHONE, "");
        UMConfigure.setLogEnabled(false);//AppConfigManage.isDebug()
    }
@@ -349,6 +365,7 @@
        });
    }
    /**
     * 初始化uni app mqtt
     */
@@ -366,6 +383,7 @@
        }
    }
    @Override
    protected void attachBaseContext(Context base) {
        MultiDex.install(base);
@@ -375,6 +393,23 @@
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext(Context context) {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());
            Configuration configuration = context.getResources().getConfiguration();
            configuration.setLocale(locale);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                configuration.setLocales(new LocaleList(locale));
            }
            return context.createConfigurationContext(configuration);
        } catch (Exception e) {
            return context;
        }
    }
    /**
     * 支持中英文切换
     */
    public Context getAppLocaleContext() {
        try {
            Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage());