| | |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | |
| | | * 上传极光注册ID到云端 |
| | | */ |
| | | private void pushTokens() { |
| | | String registrationId_tag="registrationID_"+UserConfigManage.getInstance().getUserId(); |
| | | String registrationId_tag = "registrationID_" + UserConfigManage.getInstance().getUserId(); |
| | | String is_registrationID = HDLApp.getInstance().getKey(registrationId_tag); |
| | | if (is_registrationID.equals("true")) { |
| | | //上过就没有必要在上传啦 |
| | |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端--->registrationID:" + finalRegistrationID, true); |
| | | 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:" + finalRegistrationID, true); |
| | | HdlLogLogic.print("添加极光ID到云端失败--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); |
| | | //移除监听 |
| | | HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); |
| | | //断开mqtt连接 |
| | | if (MqttRecvClient.getInstance() != null) { |
| | | MqttRecvClient.getInstance().stop(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | |
| | | viewBinding.myMessageBottomIl2.titleTv.setText(R.string.message); |
| | | viewBinding.myMeBottomIl3.titleTv.setText(R.string.power_station_me); |
| | | this.bottomViewChangeOfStyle(); |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | public void requestPermissions() { |
| | | //消息通知限权 |
| | | this.notificationSet(); |
| | | //Manifest.permission.ACCESS_COARSE_LOCATION |
| | | //ACCESS_FINE_LOCATION 允许使用GPS定位 |
| | | //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); |
| | |
| | | * 初始化mqtt客户端 |
| | | */ |
| | | public void initMqttClient() { |
| | | |
| | | HdlMqttLogic.getInstance().getMqttRemoteInfo(HomeType.A, new CloudCallBeak<MqttInfo>() { |
| | | @Override |
| | | public void onSuccess(MqttInfo info) { |
| | |
| | | |
| | | |
| | | /** |
| | | * 物理按键返回事件 |
| | | * 物理按键返回事件(包括左滑移除事件) |
| | | */ |
| | | @Override |
| | | public void onBackPressed() { |
| | |
| | | * 初始化【开启定位】和【位置信息】权限 |
| | | */ |
| | | private void locationUpdates() { |
| | | |
| | | |
| | | // 初始化LocationManager对象 |
| | | LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); |
| | | // //INTERNET 允许使用网络 |
| | | // //ACCESS_FINE_LOCATION 允许使用GPS定位 |
| | | // //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | // if (ActivityCompat.checkSelfPermission(_mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { |
| | | // // TODO: Consider calling |
| | | // // ActivityCompat#requestPermissions |
| | | // // here to request the missing permissions, and then overriding |
| | | // // public void onRequestPermissionsResult(int requestCode, String[] permissions, |
| | | // // int[] grantResults) |
| | | // // to handle the case where the user grants the permission. See the documentation |
| | | // // for ActivityCompat#requestPermissions for more details. |
| | | // return; |
| | | // } |
| | | // HdlLogLogic.print("开始纬度经度--->", false); |
| | | // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); |
| | | // |
| | | // //建议这个 minTime 不小于 60000,即 1 分钟,这样会更加高效而且省电 |
| | | // locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() { |
| | | // @Override |
| | | // public void onLocationChanged(@NonNull Location location) { |
| | | // // 当位置发生变化时调用此方法 |
| | | // double latitude = location.getLatitude(); // 获取纬度 |
| | | // double longitude = location.getLongitude(); // 获取经度 |
| | | // |
| | | // HdlLogLogic.print("纬度--->" + latitude, true); |
| | | // HdlLogLogic.print("经度--->" + longitude, true); |
| | | // } |
| | | // }); |
| | | GPSManagerUtils.getInstance().getLocation(this); |
| | | // 判断设备是否支持定位功能 |
| | | if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { |
| | | // 提示用户打开定位功能或者引导用户去系统设置页面打开定位功能 |
| | |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | //INTERNET 允许使用网络 |
| | | //ACCESS_FINE_LOCATION 允许使用GPS定位 |
| | | //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | if (ActivityCompat.checkSelfPermission(_mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { |
| | | // TODO: Consider calling |
| | | // ActivityCompat#requestPermissions |
| | | // here to request the missing permissions, and then overriding |
| | | // public void onRequestPermissionsResult(int requestCode, String[] permissions, |
| | | // int[] grantResults) |
| | | // to handle the case where the user grants the permission. See the documentation |
| | | // for ActivityCompat#requestPermissions for more details. |
| | | return; |
| | | } |
| | | HdlLogLogic.print("开始纬度经度--->", false); |
| | | // Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); |
| | | |
| | | //建议这个 minTime 不小于 60000,即 1 分钟,这样会更加高效而且省电 |
| | | locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60 * 1000, 10, new LocationListener() { |
| | | @Override |
| | | public void onLocationChanged(@NonNull Location location) { |
| | | // 当位置发生变化时调用此方法 |
| | | double latitude = location.getLatitude(); // 获取纬度 |
| | | double longitude = location.getLongitude(); // 获取经度 |
| | | |
| | | |
| | | HdlLogLogic.print("纬度--->" + latitude, false); |
| | | HdlLogLogic.print("经度--->" + longitude, false); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |