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/ui/CPowerStationActivity.java | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
index cf3ffb2..7ca79f6 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -1,6 +1,8 @@
package com.hdl.photovoltaic.ui;
+import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.SystemClock;
@@ -23,13 +25,13 @@
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
import com.hdl.photovoltaic.other.HdlESLocalJsonLogic;
-import com.hdl.photovoltaic.other.HdlFileLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMqttLogic;
import com.hdl.photovoltaic.other.HdlOtaLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
+import com.hdl.photovoltaic.services.ForeService;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
@@ -84,6 +86,18 @@
this.pushTokens();
//鑾峰彇浜戠鑴氭湰
HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
+ mForegroundService= new Intent(this, ForeService.class);
+ startService();
+ }
+
+ Intent mForegroundService;
+ private void startService(){
+ // Android 8.0浣跨敤startForegroundService鍦ㄥ墠鍙板惎鍔ㄦ柊鏈嶅姟
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
+ startForegroundService(mForegroundService);
+ } else {
+ startService(mForegroundService);
+ }
}
@Override
@@ -170,7 +184,7 @@
HdlLogLogic.print(event.getTopic() + new Gson().toJson(event.getData()), true);
} else if (event.getTopic().contains(ConstantManage.network_change_post)) {
// String wifi_ssid = WifiUtils.getInstance().getCurrentConnectWifiSsid();//鑾峰彇WiFi鐨剆sid闇�瑕佷綅缃潈闄愮殑
- HdlLogLogic.print("鐩戝惉缃戠粶鐘舵��--->" + event.getData().toString() + "(" + event.getType() + ")", true);
+ HdlLogLogic.print("鐩戝惉缃戠粶鐘舵��---" + event.getData().toString() + "(" + event.getType() + ")", true);
//绗竴娆″惎鍔ˋpp,浠ュ強鍒囨崲缃戠粶鐨勬椂鍊欐洿鏂�
if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) {
return;
@@ -309,6 +323,7 @@
HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
//绉婚櫎鐩戝惉
HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
+ stopService(mForegroundService);
}
/**
--
Gitblit v1.8.0