| | |
| | | //从内存里面获取不到语言,获取当前系统的; |
| | | String str = getResources().getConfiguration().locale.getCountry(); |
| | | if (str.equals("CN") || str.equals("TW")) { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.cn); |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | } else { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en); |
| | | } |
| | |
| | | HDLLinkPMSdk.initWithAppKey(getInstance(), AppConfigManage.getAppKey(), AppConfigManage.getAppSecret(), AppConfigManage.getAPPRegionUrl()); |
| | | //2.设置打印 |
| | | HDLLinkPMSdk.setLogEnabled(isLogEnabled); |
| | | //3.配置接口请求语言 |
| | | Locale locale = LocalManageUtil.getSystemLocale(this); |
| | | if (!locale.getLanguage().equals("zh")) { |
| | | HDLLinkPMSdk.setLanguage("en"); |
| | | } else { |
| | | HDLLinkPMSdk.setLanguage("cn"); |
| | | if (TextUtils.isEmpty(UserConfigManage.getInstance().getCurrentAppLanguage())) { |
| | | //默认配置接口请求语言是中文 |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | } |
| | | //3.配置接口请求语言 |
| | | HDLLinkPMSdk.setLanguage(UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | |
| | | // //3.配置接口请求语言 |
| | | // Locale locale = LocalManageUtil.getSystemLocale(this); |
| | | // if (!locale.getLanguage().equals("zh")) { |
| | | // HDLLinkPMSdk.setLanguage("en"); |
| | | // } else { |
| | | // HDLLinkPMSdk.setLanguage("zh"); |
| | | // } |
| | | // HDLLinkPMSdk.setLanguage("en");//强制使用英文 |
| | | //4.监听登出处理 |
| | | HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() { |
| | |
| | | HdlLogLogic.print("测试Mqtt连接服务端失败--->"); |
| | | } |
| | | } |
| | | |
| | | public void appLocationInfo() { |
| | | LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); |
| | | if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.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; |
| | | } |
| | | //开始定位服务,minTimeMs最小时间间隔(单位为毫秒),minDistanceM最小距离间隔(单位为米)、最小时间间隔(单位为毫秒)等参数。 |
| | | locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, 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); |
| | | // 这里可以根据需求处理获取到的经纬度数据 |
| | | } |
| | | |
| | | public void onStatusChanged(String provider, int status, Bundle extras) { |
| | | } |
| | | |
| | | public void onProviderEnabled(String provider) { |
| | | } |
| | | |
| | | public void onProviderDisabled(String provider) { |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |