com.google.android.gms.location.FusedLocationProviderApi类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中com.google.android.gms.location.FusedLocationProviderApi类的一些代码示例,展示了FusedLocationProviderApi类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FusedLocationProviderApi类的具体详情如下:
包路径:com.google.android.gms.location.FusedLocationProviderApi
类名称:FusedLocationProviderApi

FusedLocationProviderApi介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

@SuppressWarnings("MissingPermission")
void requestLocations() {
 PendingResult<Status> result=
   LocationServices.FusedLocationApi
    .requestLocationUpdates(getPlayServices(), request, this);
 result.setResultCallback(new ResultCallback<Status>() {
  @Override
  public void onResult(Status status) {
   if (status.isSuccess()) {
    Toast
      .makeText(getActivity(),
        R.string.location_req_success_msg,
        Toast.LENGTH_LONG)
      .show();
   } else {
    Toast
      .makeText(getActivity(), status.getStatusMessage(),
        Toast.LENGTH_LONG)
      .show();
    getActivity().finish();
   }
  }
 });
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onPause() {
 LocationServices.FusedLocationApi.removeLocationUpdates(
  getPlayServices(), this);
 super.onPause();
}

代码示例来源:origin: commonsguy/cw-omnibus

@SuppressWarnings("MissingPermission")
@Override
public void run() {
 Location location=
  LocationServices.FusedLocationApi.getLastLocation(getPlayServices());
 if (location==null) {
  getListView().postDelayed(this, 1000);
 }
 else {
  fetchForecast(location);
 }
}

代码示例来源:origin: Sishin/MapLocation

Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
    mGoogleApiClient);
if (mLastLocation != null) {
    LocationServices.FusedLocationApi.removeLocationUpdates(
        mGoogleApiClient, this);
  mLocationRequest.setFastestInterval(5000);
  mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  LocationServices.FusedLocationApi.requestLocationUpdates(
      mGoogleApiClient, mLocationRequest, this);

代码示例来源:origin: lycha/augmented-reality-example

@Override
public void onConnected(Bundle bundle) {
  LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
  mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
      mGoogleApiClient);
  if (mLastLocation != null) {
    onLocationChangedListener.onLocationChanged(mLastLocation);
  }
}

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
} catch (SecurityException e) {
  Log.e(TAG, "Security exception requesting location updates: " + e);
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);

代码示例来源:origin: yayaa/LocationManager

@SuppressWarnings("ResourceType")
boolean getLocationAvailability() {
  LocationAvailability locationAvailability =
     LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
  return locationAvailability != null && locationAvailability.isLocationAvailable();
}

代码示例来源:origin: NightscoutFoundation/xDrip

@SuppressLint("MissingPermission") final Location location = LocationServices.FusedLocationApi.getLastLocation(mApiClient);
if (location != null) {
  lastLocation = location;
    LocationServices.FusedLocationApi.requestLocationUpdates(mApiClient,
        getLocationRequest(), callback, Looper.getMainLooper());
  });
  Inevitable.task("remove gps updates " + JoH.tsl(), GPS_ACTIVE_TIME,
      () -> LocationServices.FusedLocationApi.removeLocationUpdates(mApiClient, callback));

代码示例来源:origin: WomenWhoCode/WomenWhoCode

@Override
public void onConnected(Bundle bundle) {
  Log.i(TAG, "Location services connected.");
  Location mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
  if (mCurrentLocation == null) {
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
  } else {
    mLocationCallback.handleNewLocation(mCurrentLocation);
  }
}

代码示例来源:origin: klaasnotfound/LocationAssistant

private boolean checkLocationAvailability() {
  if (!googleApiClient.isConnected() || !permissionGranted) return false;
  try {
    LocationAvailability la = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    return (la != null && la.isLocationAvailable());
  } catch (SecurityException e) {
    if (!quiet)
      Log.e(getClass().getSimpleName(), "Error while checking location availability:\n " + e.toString());
    if (listener != null)
      listener.onError(ErrorType.RETRIEVAL, "Could not check location availability:\n" +
          e.getMessage());
    return false;
  }
}

代码示例来源:origin: palaima/DebugDrawer

void startLocationUpdates() {
  googleApiClient.connect();
  if (connected && locationRequest != null) {
    isStarted = true;
    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, locationListener);
  }
}

代码示例来源:origin: jamorham/xDrip-plus

@SuppressLint("MissingPermission") final Location location = LocationServices.FusedLocationApi.getLastLocation(mApiClient);
if (location != null) {
  lastLocation = location;
    LocationServices.FusedLocationApi.requestLocationUpdates(mApiClient,
        getLocationRequest(), callback, Looper.getMainLooper());
  });
  Inevitable.task("remove gps updates " + JoH.tsl(), GPS_ACTIVE_TIME,
      () -> LocationServices.FusedLocationApi.removeLocationUpdates(mApiClient, callback));

代码示例来源:origin: ankitdubey021/GPSTracker

@Override
public void onConnected(@Nullable Bundle bundle) {
  Log.i("My Tracker", "Location services connected!.");
  if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
    return;
  }
  Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
  fetchLocation(location);
  if (location == null) {
    if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
      return;
    }
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
  }
}

代码示例来源:origin: palaima/DebugDrawer

void stopLocationUpdates() {
    if (connected && locationRequest != null) {
      LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener);
      googleApiClient.disconnect();
      connected = false;
      isStarted = false;
    }
  }
}

代码示例来源:origin: palaima/DebugDrawer

/**
 * Get last known location
 *
 * @return Location
 */
Location getLastLocation() {
  return LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
}

代码示例来源:origin: florent37/RxGps

@Override
  protected void onGoogleApiClientReady(GoogleApiClient apiClient, SingleEmitter<Boolean> emitter) {
    //noinspection MissingPermission
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(apiClient);

    if (locationAvailability != null) {
      emitter.onSuccess(locationAvailability.isLocationAvailable());
    } else {
      emitter.onSuccess(false);
    }
  }
}

代码示例来源:origin: yayaa/LocationManager

@SuppressWarnings("ResourceType")
void requestLocationUpdate() {
  LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
}

代码示例来源:origin: AppLozic/Applozic-Android-SDK

@Override
public void onConnected(Bundle bundle) {
  try {
    Location mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
    if (mCurrentLocation == null) {
      Toast.makeText(this, R.string.waiting_for_current_location, Toast.LENGTH_SHORT).show();
      locationRequest = new LocationRequest();
      locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
      locationRequest.setInterval(UPDATE_INTERVAL);
      locationRequest.setFastestInterval(FASTEST_INTERVAL);
      LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    }
    if (mCurrentLocation != null && conversation != null) {
      conversation.attachLocation(mCurrentLocation);
    }
  } catch (Exception e) {
  }
}

代码示例来源:origin: AppLozic/Applozic-Android-SDK

@Override
public void onLocationChanged(Location location) {
  try {
    LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
    if (location != null) {
      mCurrentLocation = location;
    }
  } catch (Exception e) {
  }
}

代码示例来源:origin: yayaa/LocationManager

@SuppressWarnings("ResourceType")
Location getLastLocation() {
  return LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
}

相关文章