| | |
| | | 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 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 com.umeng.analytics.MobclickAgent; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | |
| | | this.pushTokens(); |
| | | //获取云端脚本 |
| | | HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson(); |
| | | mForegroundService= new Intent(this, ForeService.class); |
| | | startService(); |
| | | // mForegroundService= new Intent(this, ForeService.class); |
| | | // startService(); |
| | | } |
| | | |
| | | Intent mForegroundService; |
| | | private void startService(){ |
| | | |
| | | private void startService() { |
| | | // Android 8.0使用startForegroundService在前台启动新服务 |
| | | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| | | startForegroundService(mForegroundService); |
| | | } else { |
| | | startService(mForegroundService); |
| | |
| | | return; |
| | | } |
| | | int index = -1; |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId(), null); |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getGatewayId().equals(topics[2])) { |
| | |
| | | } |
| | | String homeId = event.getData().toString(); |
| | | //进去住宅详情uni读取逆变器列表成功后通知 |
| | | for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).size(); i++) { |
| | | String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).get(i).getGatewayId(); |
| | | for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) { |
| | | String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId(); |
| | | //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; |
| | | String topic = "/user/" + gatewayId + "/#"; |
| | | //进去住宅详情开始订阅主题 |
| | |
| | | // } |
| | | if (TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) { |
| | | //其实刷新token失败已通知退出登录,数据已经清空,因为等2s uni加载慢导致请求链接的时候出现token为空 |
| | | HdlLogLogic.print("返回去"); |
| | | HdlLogLogic.print("返回去---", true); |
| | | return; |
| | | } |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0); |
| | |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 物理按键返回事件(包括左滑移除事件) |
| | |
| | | HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); |
| | | } |
| | | AppManagerUtils.getAppManager().finishAllActivity(); |
| | | //如果开发者调用kill或者exit之类的方法杀死进程,或者双击back键会杀死进程,请务必在此之前调用MobclickAgent.onKillProcess方法,用来保存统计数据。 |
| | | MobclickAgent.onKillProcess(_mActivity); |
| | | // //友盟sdk如果开发者调用kill或者exit之类的方法杀死进程,或者双击back键会杀死进程,请务必在此之前调用MobclickAgent.onKillProcess方法,用来保存统计数据。 |
| | | // MobclickAgent.onKillProcess(_mActivity); |
| | | Process.killProcess(Process.myPid()); |
| | | } |
| | | } |
| | |
| | | HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); |
| | | //移除监听 |
| | | HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); |
| | | stopService(mForegroundService); |
| | | // stopService(mForegroundService); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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);//逆变器wifi状态-重新搜索一下逆变器-重新更新连接状态 |
| | | } |
| | | |
| | | } |