From 5a43cb75120f69a57d5238e855eef8e82b3e4544 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期五, 25 四月 2025 13:15:22 +0800
Subject: [PATCH] 加了前台服务

---
 app/src/main/java/com/hdl/photovoltaic/HDLApp.java |   48 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
index 98ba351..2ddf9e6 100644
--- a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
+++ b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -7,6 +7,7 @@
 import android.content.res.Configuration;
 import android.os.Build;
 import android.os.LocaleList;
+import android.os.Process;
 import android.os.SystemClock;
 import android.text.TextUtils;
 import android.util.Log;
@@ -42,6 +43,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;
 
@@ -59,6 +61,7 @@
 
 public class HDLApp extends Application {
 
+    final String TAG=HDLApp.class.getName();
     //鎺у埗鎵撳嵃 Debug妯″紡鎵撳嵃
     private Boolean isLogEnabled = true;
     //涓夋柟sdk鍒濆鍖栨爣璇�
@@ -84,7 +87,12 @@
     public void onCreate() {
         super.onCreate();
         // 鑾峰彇褰撳墠杩涚▼鐨凱ID
-        Log.d("杩涚▼===", android.os.Process.myPid() + "");
+        String processMessage= "杩涚▼ID:"+Process.myPid()+" 杩涚▼鍚嶏細"+RuningAcitvityUtil.getAppName(getBaseContext());
+        Log.d(TAG, processMessage);
+        if (RuningAcitvityUtil.getAppName(getBaseContext()).contains(":")) {
+            //闈炲師鐢熻繘绋嬶紝鐢ㄥ垵濮嬪寲鍚庨潰鐨�
+            return;
+        }
         mHDLApp = this;
         SharedPreUtils.init(this);
         getAppLanguage();
@@ -99,8 +107,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 +178,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()
     }
 
 
@@ -349,6 +372,7 @@
         });
     }
 
+
     /**
      * 鍒濆鍖杣ni app mqtt
      */
@@ -366,6 +390,7 @@
         }
     }
 
+
     @Override
     protected void attachBaseContext(Context base) {
         MultiDex.install(base);
@@ -375,6 +400,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