| | |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.connect.HDLUdpConnect; |
| | | 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; |
| | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | //// //通知栏点击进来,防止应用在后台时被重复启动,阿里云推动通知指定打开某个Activity,没有设置Flags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);默认启动新实例,导致多个实例 |
| | | // if (!isTaskRoot()) { |
| | | // finish(); |
| | | // } |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E)); |
| | | //初始化碎片 |
| | |
| | | if (TextUtils.isEmpty(data)) { |
| | | return; |
| | | } |
| | | // PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class); |
| | | PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data); |
| | | if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) { |
| | | return; |
| | |
| | | |
| | | |
| | | /** |
| | | * 上传极光注册ID到云端 |
| | | */ |
| | | private void pushTokens() { |
| | | String registrationId_tag = "registrationID_" + UserConfigManage.getInstance().getUserId(); |
| | | String is_registrationID = HDLApp.getInstance().getKey(registrationId_tag); |
| | | if (is_registrationID.equals("true")) { |
| | | //上过就没有必要在上传啦 |
| | | return; |
| | | } |
| | | |
| | | HdlThreadLogic.runSubThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | String registrationID = JPushInterface.getRegistrationID(_mActivity); |
| | | int addCount = 0; |
| | | while (TextUtils.isEmpty(registrationID)) { |
| | | SystemClock.sleep(1000);//1s休眠 |
| | | registrationID = JPushInterface.getRegistrationID(_mActivity); |
| | | addCount++; |
| | | if (addCount > 5) { |
| | | //5s超时 |
| | | break; |
| | | } |
| | | } |
| | | if (!TextUtils.isEmpty(registrationID)) { |
| | | // UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | // UserConfigManage.getInstance().Save(); |
| | | String finalRegistrationID = registrationID; |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | |
| | | if (!TextUtils.isEmpty(pushId)) { |
| | | UserConfigManage.getInstance().setPushToken(finalRegistrationID); |
| | | UserConfigManage.getInstance().setPushId(pushId); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端失败---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 上传 token 到服务器 |
| | | * |
| | | * @param token 令牌 |
| | | */ |
| | | private void sendPushTokenToServer(final String token) { |
| | | |
| | | if (TextUtils.isEmpty(token)) { |
| | | return; |
| | | } |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true); |
| | |
| | | showFragment(); |
| | | } |
| | | } else if (event.getTopic().contains(ConstantManage.refresh_push_token)) { |
| | | String token=event.getType(); |
| | | String token = event.getType(); |
| | | UserConfigManage.getInstance().setPushToken(token); |
| | | UserConfigManage.getInstance().Save(); |
| | | //pushToken更新 |
| | |
| | | //触发消息点击事件 |
| | | viewBinding.myMessageBottomIl2.clickTv.performClick(); |
| | | // if (currentFragmentIndex == 2) { |
| | | // HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); |
| | | // return; |
| | | // } |
| | | // currentFragmentIndex = 2; |
| | | // bottomViewChangeOfStyle(); |
| | | // showFragment(); |
| | | // HdlCommonLogic.lowerTagType = LowerTagType.message; |
| | | // HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString()); |
| | | // HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house); |
| | | } |
| | | |
| | | |
| | |
| | | return; |
| | | } else { |
| | | AppManagerUtils.getAppManager().finishAllActivity(); |
| | | //如果开发者调用kill或者exit之类的方法杀死进程,或者双击back键会杀死进程,请务必在此之前调用MobclickAgent.onKillProcess方法,用来保存统计数据。 |
| | | MobclickAgent.onKillProcess(_mActivity); |
| | | // //友盟sdk如果开发者调用kill或者exit之类的方法杀死进程,或者双击back键会杀死进程,请务必在此之前调用MobclickAgent.onKillProcess方法,用来保存统计数据。 |
| | | // MobclickAgent.onKillProcess(_mActivity); |
| | | Process.killProcess(Process.myPid()); |
| | | |
| | | } |