管灌系统巡查员智能手机App
app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
@@ -67,7 +67,9 @@
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        MyLog.i("onStartCommand()");
        isSingle = intent.getBooleanExtra("isSingle", false);
        if (intent != null) {
            isSingle = intent.getBooleanExtra("isSingle", false);
        }
        if (!isSingle) {
            // 在API11之后构建Notification的方式
            Notification.Builder builder = new Notification.Builder
@@ -159,7 +161,7 @@
                MyLog.i("原生定位没有权限>>>>");
                return;
            }
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1000, 0, listener);
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, listener);
        } catch (Exception e) {
            CrashReport.postCatchedException(e);
        }
@@ -219,13 +221,13 @@
            String longitude = "Longitude:" + location.getLongitude();
            String latitude = "Latitude:" + location.getLatitude();
            MyLog.i("原生定位onLocationChanged:  Latitude:" + latitude + "  Longitude:" + longitude);
            MyLog.d("原生定位onLocationChanged:  Latitude:" + latitude + "  Longitude:" + longitude);
            postPosition(location.getLatitude(), location.getLongitude());
//            是否一次性定位
            if (isSingle) {
                stopSelf();  // 获取到经纬度以后,停止该service
            }
            ToastUtil.showToast(MyLocationService.this, "原生定位onLocationChanged:  Latitude:" + latitude + "  Longitude:" + longitude);
//            ToastUtil.showToast(MyLocationService.this, "原生定位onLocationChanged:  Latitude:" + latitude + "  Longitude:" + longitude);
        }
        // 状态改变时