wjc
2025-04-25 18aad0f6f20ce89e2e904a59952f72c194ce085b
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;
@@ -29,6 +31,7 @@
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;
@@ -83,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
@@ -308,6 +323,7 @@
        HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
        //移除监听
        HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
        stopService(mForegroundService);
    }
    /**