From a17869744eeea710c9ee15eadb3837cd4ed0bcd7 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 25 四月 2025 13:38:46 +0800
Subject: [PATCH] 2025年04月25日13:38:44

---
 app/src/main/java/com/hdl/photovoltaic/HDLApp.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
index 3aa0e42..9179397 100644
--- a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
+++ b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -41,6 +41,8 @@
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 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;
 
@@ -98,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);
@@ -169,8 +171,23 @@
         this.networkMonitoring();
         //鍒濆鍖栨湰鍦癮ssets鏂囦欢澶硅祫婧愭枃浠�
 //        this.initLocalAssetsData();
+        //鍒濆鍖栧弸鐩烻DK
+        initUMengSDK();
 
 
+    }
+
+    /**
+     * 鍒濆鍖栧弸鐩烻DK锛屾姄闂��鏃ュ織
+     * 闆嗘垚鏁欑▼鍦板潃锛歨ttps://developer.umeng.com/docs/119267/detail/118588
+     */
+    private void initUMengSDK() {
+        UMConfigure.preInit(this, "6801aec0bc47b67d833fd76d", "XenterraSolar");
+        //appkey鍜宑hannl蹇呴』淇濇寔鍜岄鍒濆鍖栦竴鑷达紒锛侊紒
+        //deviceType锛氳澶囩被鍨嬶紝UMConfigure.DEVICE_TYPE_PHONE涓烘墜鏈恒�乁MConfigure.DEVICE_TYPE_BOX涓虹洅瀛�
+        //pushSecret锛歅ush鎺ㄩ�佷笟鍔$殑secret
+        UMConfigure.init(this, "6801aec0bc47b67d833fd76d", "XenterraSolar", UMConfigure.DEVICE_TYPE_PHONE, "");
+        UMConfigure.setLogEnabled(false);//AppConfigManage.isDebug()
     }
 
 
@@ -202,11 +219,13 @@
         HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() {
             @Override
             public void onReLogin(int type) {
-                HdlLogLogic.print("閫�鍒扮櫥褰曠晫闈�---" + type, true);
+                HdlLogLogic.print("鐩戝惉鍒扮櫥褰曢��鍑�---" + type, true);
                 //type:  0:姝e父閫�鍑�   1锛氭瀬鍏夋帹閫佸己鍒堕��鍑�
                 //鏀跺埌鐧诲綍澶勭悊閫氱煡锛屽叧闂墍鏈夐〉闈㈠苟鎵撳紑鐧诲綍椤甸潰
                 AppManagerUtils.getAppManager().finishAllActivity();
 //                HDLSDKSPUtils.clear();//搴曞眰鑷繁娓呯┖
+
+                HdlLogLogic.print("椤甸潰澶у皬---" + AppManagerUtils.getAppManager().getActivitySize());
 
                 //閲嶆柊鐧婚檰,榛樿鍚屾剰闅愮鏀跨瓥
                 UserConfigManage.getInstance().setAcceiptPolicy(false);
@@ -224,10 +243,10 @@
                 if (mInfoMap != null) {
                     mInfoMap.clear();
                 }
-//                //鏂紑mqtt杩炴帴
-//                if (MqttRecvClient.getInstance() != null) {
-//                    MqttRecvClient.getInstance().disConnect();
-//                }
+                //鏂紑mqtt杩炴帴
+                if (MqttRecvClient.getInstance() != null) {
+                    MqttRecvClient.getInstance().disConnect();
+                }
                 //鏂紑鎵�鏈塼cp杩炴帴涓旀竻绌鸿繛鎺ョ紦瀛�
                 // TODO: 10/10/23
 //                TcpSocketBoot.stopAllConnectLinkGateway();
@@ -242,6 +261,7 @@
                     intent.putExtra("isJpush", true);
                 }
                 startActivity(intent);
+                HdlLogLogic.print("椤甸潰澶у皬---" + AppManagerUtils.getAppManager().getActivitySize());
 
             }
         });
@@ -348,6 +368,7 @@
         });
     }
 
+
     /**
      * 鍒濆鍖杣ni app mqtt
      */
@@ -365,6 +386,7 @@
         }
     }
 
+
     @Override
     protected void attachBaseContext(Context base) {
         MultiDex.install(base);
@@ -374,6 +396,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());

--
Gitblit v1.8.0