| | |
| | | import com.dayu.pipirrapp.tool.GlideEngine; |
| | | import com.dayu.pipirrapp.tool.ImageFileCompressEngine; |
| | | import com.dayu.pipirrapp.utils.CommonKeyName; |
| | | import com.dayu.pipirrapp.utils.ServiceUtils; |
| | | import com.dayu.pipirrapp.utils.ToastUtil; |
| | | import com.dayu.pipirrapp.view.TitleBar; |
| | | import com.jeremyliao.liveeventbus.LiveEventBus; |
| | |
| | | /** |
| | | * 定位监听 |
| | | */ |
| | | private Observer<Object> locationObserver = new Observer<Object>() { |
| | | private final Observer<Object> locationObserver = new Observer<Object>() { |
| | | @Override |
| | | public void onChanged(Object o) { |
| | | latLonBean = (LatLonBean) o; |
| | |
| | | * 开始定位相关逻辑 |
| | | */ |
| | | private void startLocation() { |
| | | Intent location = new Intent(this, MyLocationService.class); |
| | | location.putExtra("isSingle", true); |
| | | //开启定位 |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| | | startForegroundService(location); |
| | | } else { |
| | | startService(location); |
| | | if (!ServiceUtils.isServiceRunning(this, MyLocationService.class)) { |
| | | Intent location = new Intent(this, MyLocationService.class); |
| | | location.putExtra("isSingle", true); |
| | | //开启定位 |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| | | startForegroundService(location); |
| | | } else { |
| | | startService(location); |
| | | } |
| | | } |
| | | //获取定位服务传过来的坐标点 |
| | | LiveEventBus.get(CommonKeyName.locationData).observeForever(locationObserver); |