Java 类com.google.android.gms.location.LocationResult 实例源码

项目:home-assistant-Android    文件:LocationUpdateReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    prefs = Utils.getPrefs(context);
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
        case ACTION_START_LOCATION:
            apiClient = new GoogleApiClient.Builder(context)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(LocationServices.API)
                    .build();

            apiClient.connect();
            break;
        case ACTION_LOCATION_UPDATE:
            if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && LocationResult.hasResult(intent)) {
                LocationResult result = LocationResult.extractResult(intent);
                Location location = result.getLastLocation();
                if (location != null)
                    logLocation(location, context);
            }
            break;
    }
}
项目:RxTask    文件:RxFusedLocationProviderClient.java   
@NonNull
@RequiresPermission(
        anyOf = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission" +
                ".ACCESS_FINE_LOCATION"}
)
public Observable<LocationResult> requestLocationRequestUpdates(LocationRequest request) {
    return ObservableTask.create(callback -> {
        LocationCallback resultCallback = new LocationCallback() {
            @Override
            public void onLocationResult(LocationResult result) {
                super.onLocationResult(result);
                callback.onNext(result);
            }
        };
        callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
        return client.requestLocationUpdates(request, resultCallback, null);
    });
}
项目:background-location-updates-android-o    文件:LocationUpdatesBroadcastReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(
                        context, locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(context));
            }
        }
    }
}
项目:background-location-updates-android-o    文件:LocationUpdatesIntentService.java   
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                LocationResultHelper locationResultHelper = new LocationResultHelper(this,
                        locations);
                // Save the location data to SharedPreferences.
                locationResultHelper.saveResults();
                // Show notification with the location data.
                locationResultHelper.showNotification();
                Log.i(TAG, LocationResultHelper.getSavedLocationResult(this));
            }
        }
    }
}
项目:poznaj-app-android    文件:LocationService.java   
@Override
public void onCreate() {
    fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

    locationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            onNewLocation(locationResult.getLastLocation());
        }
    };

    createLocationRequest();
    getLastLocation();

    HandlerThread handlerThread = new HandlerThread(TAG);
    handlerThread.start();
    serviceHandler = new Handler(handlerThread.getLooper());
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
项目:autotracks-android    文件:LocationUpdatesService.java   
@Override
protected void onHandleIntent(Intent intent) {
     if (mPreferenceUtils.isActivityUpdatesStarted()) {
        if (mPreferenceUtils.isLocationUpdatesStarted()) {
            if (LocationResult.hasResult(intent)) {
                LocationResult locationResult = LocationResult.extractResult(intent);
                Location location = locationResult.getLastLocation();
                saveLocation(location);
            }
            long currentTime = System.currentTimeMillis();
            long tolerance = mPreferenceUtils.getActivityRecognitionToleranceMillis();
            long lastActivityTime = mPreferenceUtils.getLastActivityTime();
            long elapsedTime = currentTime - lastActivityTime;
            if (elapsedTime > tolerance) {
                mLocationUpdatesController.stopLocationUpdates();
            }
        }
    }
}
项目:NightSkyGuide    文件:MainActivity.java   
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
        super.onLocationResult(locationResult);
        mCurrentLocation = locationResult.getLastLocation();
        setLatLong(mCurrentLocation);
        //Toast.makeText(MainActivity.this, "GPS Update", Toast.LENGTH_SHORT).show();
        }
    };
}
项目:NightSkyGuide    文件:SettingsActivity.java   
public void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            mCurrentLocation = locationResult.getLastLocation();
            setLatLong(mCurrentLocation);
        }
    };
}
项目:SpaceRace    文件:MapActivity.java   
/**
 * Creates a callback for receiving location events.
 */
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(final LocationResult locationResult) {
            super.onLocationResult(locationResult);

            if (mRequestingLocationUpdates) {

                Log.i(TAG, "update event");
                Location oldLocation = mCurrentLocation;

                mCurrentLocation = locationResult.getLastLocation();

                if (initialPosition == null) {
                    initialPosition = mCurrentLocation;

                    map.moveCamera(CameraUpdateFactory.newLatLngZoom(
                            new LatLng(initialPosition.getLatitude(),
                                    initialPosition.getLongitude()), DEFAULT_ZOOM));

                    Log.d("INITIAL_POSITION", initialPosition.getLatitude() + " " +
                            initialPosition.getLongitude());

                    createAndDrawPath();
                }

                mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
                updateUI(oldLocation);
            }

        }
    };
}
项目:LocationAware    文件:LocationAwareService.java   
@Override public void onLocationResult(LocationResult locationResult) {
  for (Location location : locationResult.getLocations()) {
    Log.i("Debug ", "On Location Available " + location.toString());
    currentLocation = location;
    matchForCheckPoints();
  }
}
项目:LocationServices    文件:LocationFragment.java   
@DebugLog
@Override
public void onLocationResult(LocationResult locationResult) {
    super.onLocationResult(locationResult);
    Location lastLocation = locationResult.getLastLocation();
    updatePosition(lastLocation);
}
项目:FiveMinsMore    文件:TrackingService.java   
@WorkerThread
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    count++;
    if (LocationResult.hasResult(intent)) {
        // 從fusedLocationApi取得位置資料
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            succeed++;

            // 若小於最小間距,則不紀錄該航跡
            if (mTrkpts.size() > 1) {
                double interval = SphericalUtil.computeDistanceBetween(
                        new LatLng(location.getLatitude(), location.getLongitude()),
                        new LatLng(mLastPosition.getLatitude(), mLastPosition.getLongitude()));
                if (interval < DISTANCE_INTERVAL_FOR_TRKPTS)
                    return START_STICKY;
            }

            mTrkpts.add(location);
            mLastPosition = location;

            // Send Location Update to Activity
            if (callBack != null)
                callBack.getServiceData(location);
        }
    }

    // Message for testing
    Log.d(TAG, "Record Times: " + count + ", Succeed times: " + succeed +
            ",  Points number: " + mTrkpts.size()
            + ", Time from start: " + (new Date().getTime() - startTime) / 1000);

    return START_STICKY;
}
项目:Sega    文件:ProductSoldFragmentPersonal.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
项目:Sega    文件:ProductListFragment.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
项目:Sega    文件:ProductSoldFragmentProfile.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
项目:Sega    文件:ProductFragmentProfile.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
项目:Sega    文件:ProductFragmentPersonal.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
项目:RxTask    文件:RequestLocationResultObservable.java   
@SuppressLint("MissingPermission")
@Override
protected Task<Void> run(ObservableTaskCallback<LocationResult> callback) {
    ResultCallback resultCallback = new ResultCallback(callback);
    callback.setDisposeListener(() -> client.removeLocationUpdates(resultCallback));
    return client.requestLocationUpdates(this.request, resultCallback, null);
}
项目:BLE-Indoor-Positioning    文件:AndroidLocationProvider.java   
private LocationCallback createLocationCallback() {
    return new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            Log.v(TAG, "Received location result with " + locationResult.getLocations().size() + " locations");
            onLocationUpdateReceived(locationResult.getLastLocation());
        }
    };
}
项目:WeatherPlus    文件:MainActivity.java   
private void createLocationCallBack() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);

            mResultCallBack.onSuccess(locationResult.getLastLocation());
            stopLocationUpdates();
        }
    };
}
项目:Camera-warner    文件:LocationService.java   
@Override
public void onCreate() {
    super.onCreate();

    Log.d("LocationService", "onCreate");

    manager = new DataProviderManager();
    manager.addObserver(this);

    mClient = LocationServices.getFusedLocationProviderClient(this);

    //implementation of the location update callback
    //what happens when the service receives the user location is defined here
    callback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            lastLocation = locationResult.getLastLocation();
            Log.d("LocationService", "new location received");
            notifyUIOfNewPosition();
            //update the location providers with the new location
            manager.onLocationChanged(lastLocation);

            if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(getString(R.string.pref_active_key), getResources().getBoolean(R.bool.pref_active_default))
                    && manager.isCameraNearerThan(Float.parseFloat(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(R.string.pref_radius_key), getString(R.string.pref_radius_default))), lastLocation)) {
                enableCameraWarning();
            } else {
                disableCameraWarning();
            }

        }
    };

    //build the notification for @see {@link #startForeground()} to keep the service from being killed
    startForeground(CAMERA_FOREGROUND_SERVICE_NOTIFICATION_ID, buildForegroundNotification());
}
项目:TrekAdvisor    文件:LocationService.java   
@Override
public void onCreate() {
    EventBus.getDefault().register(this);

    // Start up the thread running the service.  Note that we create a
    // separate thread because the service normally runs in the process's
    // main thread, which we don't want to block.  We also make it
    // background priority so CPU-intensive work will not disrupt our UI.
    HandlerThread thread = new HandlerThread("LocationServiceThread",
            Thread.MIN_PRIORITY);
    thread.start();

    // Get the HandlerThread's Looper and use it for our Handler
    mServiceLooper = thread.getLooper();
    mServiceHandler = new Handler(mServiceLooper);

    mServiceHandler.handleMessage(new Message());

    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getApplicationContext());
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    /* Create the Gpx instance */
    mTrackPoints = new ArrayList<>();

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            for (Location location : locationResult.getLocations()) {
                mServiceHandler.post(() -> {
                    TrackPoint.Builder pointBuilder = new TrackPoint.Builder();
                    pointBuilder.setLatitude(location.getLatitude());
                    pointBuilder.setLongitude(location.getLongitude());
                    pointBuilder.setElevation(location.getAltitude());

                    TrackPoint trackPoint = pointBuilder.build();
                    mTrackPoints.add(trackPoint);
                });
            }
        }
    };

    startLocationUpdates();
}
项目:TrekAdvisor    文件:MapViewFragment.java   
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof RequestManageTracksListener
            && context instanceof RequestManageMarkerListener
            && context instanceof MapProvider) {
        mRequestManageTracksListener = (RequestManageTracksListener) context;
        mRequestManageMarkerListener = (RequestManageMarkerListener) context;
        mMapProvider = (MapProvider) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement RequestManageTracksListener, MapProvider and LocationProvider");
    }

    /* The Google api client is re-created here as the onAttach method will always be called for
     * a retained fragment.
     */
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getActivity().getApplicationContext());
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            for (Location location : locationResult.getLocations()) {
                onLocationReceived(location);
            }
        }
    };
}
项目:Tower-develop    文件:GoogleMapFragment.java   
@Override
public void onLocationResult(LocationResult result) {
    super.onLocationResult(result);

    final Location location = result.getLastLocation();
    if (location == null)
        return;

    //Update the user location icon.
    if (userMarker == null) {
        final MarkerOptions options = new MarkerOptions()
                .position(new LatLng(location.getLatitude(), location.getLongitude()))
                .draggable(false)
                .flat(true)
                .visible(true)
                .anchor(0.5f, 0.5f)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.user_location));

        getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                userMarker = googleMap.addMarker(options);
            }
        });
    } else {
        userMarker.setPosition(new LatLng(location.getLatitude(), location.getLongitude()));
    }

    if (mPanMode.get() == AutoPanMode.USER) {
        Timber.d("User location changed.");
        updateCamera(MapUtils.locationToCoord(location), (int) getMap().getCameraPosition().zoom);
    }

    if (mLocationListener != null) {
        mLocationListener.onLocationChanged(location);
    }
}
项目:FMTech    文件:fda.java   
public final void handleMessage(Message paramMessage)
{
  switch (paramMessage.what)
  {
  default: 
    return;
  case 0: 
    this.a.a((LocationResult)paramMessage.obj);
    return;
  }
  this.a.a((LocationAvailability)paramMessage.obj);
}
项目:FMTech    文件:fvw.java   
public Location a()
{
  LocationResult localLocationResult = this.a;
  int i = localLocationResult.c.size();
  if (i == 0) {
    return null;
  }
  return (Location)localLocationResult.c.get(i - 1);
}
项目:googleplayAPI    文件:MainActivity.java   
/**
 * Creates a callback for receiving location events.
 */
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);

            mLastLocation = locationResult.getLastLocation();
            logger.append("\n\n" + DateFormat.getTimeInstance().format(new Date()) + ": ");
            logger.append(" Lat: " + String.valueOf(mLastLocation.getLatitude()));
            logger.append(" Long: " + String.valueOf(mLastLocation.getLongitude()) + "\n");
            startIntentService();
        }
    };
}
项目:googleplayAPI    文件:MainActivity.java   
/**
 * Creates a callback for receiving location events.
 */
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);

            addData(locationResult.getLastLocation());
        }
    };
}
项目:drivedata    文件:CaptureActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
项目:drivedata    文件:CaptureActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
项目:androidApp    文件:PositionProvider.java   
private PositionProvider(Context context) {
    Log.d(TAG, "Constructor");
    fusedLocationProviderClient = new FusedLocationProviderClient(context);
    locationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            Log.d(TAG, "onLocationResult");
            onLocationChanged(locationResult.getLastLocation());
        }
    };
    listeners = new SortedList<>(PositionProviderListener.class, new InnerCallback());
    buildGoogleApiClient(context);
    Location location = new Location("");

    double last_latitude = Double.longBitsToDouble(TranSappApplication.getAppSharedPreferences()
            .getLong(PositionProvider.USER_LATITUDE, 0));
    last_latitude = last_latitude != 0 ? last_latitude : Constants.santiagoLatitude;

    double last_longitude = Double.longBitsToDouble(TranSappApplication.getAppSharedPreferences()
            .getLong(PositionProvider.USER_LONGITUDE, 0));
    last_longitude = last_longitude != 0 ? last_longitude : Constants.santiagoLongitude;

    Log.d(TAG, "load latitude: " + last_latitude);
    Log.d(TAG, "load longitude: " + last_longitude);
    location.setLatitude(last_latitude);
    location.setLongitude(last_longitude);
    lasKnownLocation = location;
}
项目:android-play-location    文件:MainActivity.java   
/**
 * Creates a callback for receiving location events.
 */
private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);

            mCurrentLocation = locationResult.getLastLocation();
            mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
            updateLocationUI();
        }
    };
}
项目:android-play-location    文件:LocationUpdatesService.java   
@Override
public void onCreate() {
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            onNewLocation(locationResult.getLastLocation());
        }
    };

    createLocationRequest();
    getLastLocation();

    HandlerThread handlerThread = new HandlerThread(TAG);
    handlerThread.start();
    mServiceHandler = new Handler(handlerThread.getLooper());
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    // Android O requires a Notification Channel.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = getString(R.string.app_name);
        // Create the channel for the notification
        NotificationChannel mChannel =
                new NotificationChannel(CHANNEL_ID, name, NotificationManager.IMPORTANCE_DEFAULT);

        // Set the Notification Channel for the Notification Manager.
        mNotificationManager.createNotificationChannel(mChannel);
    }
}
项目:android-play-location    文件:LocationUpdatesBroadcastReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                Utils.setLocationUpdatesResult(context, locations);
                Utils.sendNotification(context, Utils.getLocationResultTitle(context, locations));
                Log.i(TAG, Utils.getLocationUpdatesResult(context));
            }
        }
    }
}
项目:android-play-location    文件:LocationUpdatesIntentService.java   
@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_PROCESS_UPDATES.equals(action)) {
            LocationResult result = LocationResult.extractResult(intent);
            if (result != null) {
                List<Location> locations = result.getLocations();
                Utils.setLocationUpdatesResult(this, locations);
                Utils.sendNotification(this, Utils.getLocationResultTitle(this, locations));
                Log.i(TAG, Utils.getLocationUpdatesResult(this));
            }
        }
    }
}
项目:WalkMyAndroid-Location    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLocationButton = (Button) findViewById(R.id.button_location);
    mLocationTextView = (TextView) findViewById(R.id.textview_location);
    mAndroidImageView = (ImageView) findViewById(R.id.imageview_android);


    // Initialize the FusedLocationClient.
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(
            this);

    // Set up the animation.
    mRotateAnim = (AnimatorSet) AnimatorInflater.loadAnimator
            (this, R.animator.rotate);
    mRotateAnim.setTarget(mAndroidImageView);

    // Restore the state if the activity is recreated.
    if (savedInstanceState != null) {
        mTrackingLocation = savedInstanceState.getBoolean(
                TRACKING_LOCATION_KEY);
    }

    // Set the listener for the location button.
    mLocationButton.setOnClickListener(new View.OnClickListener() {
        /**
         * Toggle the tracking state.
         * @param v The track location button.
         */
        @Override
        public void onClick(View v) {
            if (!mTrackingLocation) {
                startTrackingLocation();
                mTrackingLocation = true;
            } else {
                stopTrackingLocation();
                mTrackingLocation = false;
            }
        }
    });

    // Initialize the location callbacks.
    mLocationCallback = new LocationCallback() {
        /**
         * This is the callback that is triggered when the
         * FusedLocationClient updates your location.
         * @param locationResult The result containing the device location.
         */
        @Override
        public void onLocationResult(LocationResult locationResult) {
            // If tracking is turned on, reverse geocode into an address
            if (mTrackingLocation) {
                new FetchAddressTask().execute(locationResult
                        .getLastLocation());
            }
        }
    };
}
项目:RxTask    文件:RequestLocationResultObservable.java   
public ResultCallback(ObservableTaskCallback<LocationResult> callback) {
    this.callback = callback;
}
项目:RxTask    文件:RequestLocationResultObservable.java   
@Override
public void onLocationResult(LocationResult result) {
    super.onLocationResult(result);
    callback.onNext(result);
}
项目:FMTech    文件:fcz.java   
public final void a(LocationResult paramLocationResult)
{
  a(0, paramLocationResult);
}
项目:FMTech    文件:fwh.java   
public final void a(LocationResult paramLocationResult)
{
  this.a.a(new fvw(this, paramLocationResult));
}