From 80f2ca2df62ff1cd03046864af504245be078eb2 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 05 六月 2025 10:37:28 +0800 Subject: [PATCH] 2025年06月05日10:37:26 --- app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 4 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 4cc4924..bdb7fd7 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,10 @@ package com.hdl.photovoltaic.ui; +import android.app.ActivityManager; +import android.content.Context; +import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Process; import android.os.SystemClock; @@ -23,13 +27,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; @@ -44,6 +48,7 @@ import com.hdl.sdk.link.core.bean.gateway.GatewayBean; import com.hdl.sdk.link.core.config.HDLLinkConfig; import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; +import com.umeng.analytics.MobclickAgent; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -83,6 +88,19 @@ 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 @@ -169,7 +187,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; @@ -231,12 +249,12 @@ // } if (TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) { //鍏跺疄鍒锋柊token澶辫触宸查�氱煡閫�鍑虹櫥褰曪紝鏁版嵁宸茬粡娓呯┖锛屽洜涓虹瓑2s uni鍔犺浇鎱㈠鑷磋姹傞摼鎺ョ殑鏃跺�欏嚭鐜皌oken涓虹┖ - HdlLogLogic.print("杩斿洖鍘�"); + HdlLogLogic.print("杩斿洖鍘�---", true); return; } UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0); List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); - if (HouseIdList.size() == 0) { + if (HouseIdList.isEmpty()) { if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; HdlUniLogic.getInstance().openUniMP(path, null); @@ -258,7 +276,9 @@ String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); HdlUniLogic.getInstance().openUniMP(path, null); } + } + // /** // * 鐗╃悊鎸夐敭杩斿洖浜嬩欢(鍖呮嫭宸︽粦绉婚櫎浜嬩欢) @@ -294,6 +314,8 @@ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); } AppManagerUtils.getAppManager().finishAllActivity(); + //濡傛灉寮�鍙戣�呰皟鐢╧ill鎴栬�卐xit涔嬬被鐨勬柟娉曟潃姝昏繘绋嬶紝鎴栬�呭弻鍑籦ack閿細鏉�姝昏繘绋嬶紝璇峰姟蹇呭湪姝や箣鍓嶈皟鐢∕obclickAgent.onKillProcess鏂规硶锛岀敤鏉ヤ繚瀛樼粺璁℃暟鎹�� + MobclickAgent.onKillProcess(_mActivity); Process.killProcess(Process.myPid()); } } @@ -306,6 +328,7 @@ HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); //绉婚櫎鐩戝惉 HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); +// stopService(mForegroundService); } /** @@ -452,7 +475,26 @@ } + } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) { + //璁惧鐘舵�佸彉鏇磘opic锛�/user/${homeId}/app/thing/property/send + if (linkResponse.getData() == null) { + HdlLogLogic.print("璁惧鐘舵�佸彉鏇�--->鏁版嵁涓虹┖", false); + return; + } + HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); + uniCallBackBaseBean.setType(linkResponse.getTopic()); + uniCallBackBaseBean.setData(linkResponse.getData()); + HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); + } else if (linkResponse.getTopic().endsWith("custom/wifi/notify")) { + //閫嗗彉鍣ㄨ繛鎺ヨ矾鐢辩姸鎬侀�氱煡 +// HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); +// uniCallBackBaseBean.setType(linkResponse.getTopic()); +// uniCallBackBaseBean.setData(linkResponse.getData()); +// HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); + HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); +// HdlDeviceLogic.getInstance().searchAllNetworkGateway(null);//閫嗗彉鍣╳ifi鐘舵��-閲嶆柊鎼滅储涓�涓嬮�嗗彉鍣�-閲嶆柊鏇存柊杩炴帴鐘舵�� } + } } }; -- Gitblit v1.8.0