| | |
| | | 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")) { |
| | | //上过就没有必要在上传啦 |
| | |
| | | * 初始化【开启定位】和【位置信息】权限 |
| | | */ |
| | | 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); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |