| | |
| | | package com.hdl.photovoltaic; |
| | | |
| | | import android.app.Application; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.location.Location; |
| | | import android.location.LocationListener; |
| | | import android.location.LocationManager; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.core.app.ActivityCompat; |
| | | |
| | | import com.hdl.hdlhttp.HxHttpConfig; |
| | | import com.hdl.linkpm.sdk.HDLLinkPMSdk; |
| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.enums.NetworkType; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.HomeLoginActivity; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | |
| | | SharedPreUtils.init(this); |
| | | getAppLanguage(); |
| | | initThirdSDK(); |
| | | // appLocationInfo(); |
| | | |
| | | } |
| | | |
| | | public void getAppLanguage() { |
| | |
| | | //从内存里面获取不到语言,获取当前系统的; |
| | | String str = getResources().getConfiguration().locale.getCountry(); |
| | | if (str.equals("CN") || str.equals("TW")) { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.cn); |
| | | } else { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |