use of com.facebook.places.model.CurrentPlaceRequestParams in project facebook-android-sdk by facebook.
the class PlaceManager method newCurrentPlaceRequest.
/**
* Creates a new current place request.
* <p>
* The current place request estimates the place where the user is currently located.
* The response contains a list of places and their associated confidence levels.
* <p>
* If a location is not specified in {@link CurrentPlaceRequestParams}, then the SDK
* retrieves the current location using {@link android.location.LocationManager}.
*
* @param requestParams the request parameters. See {@link CurrentPlaceRequestParams}
* @param callback a {@link OnRequestReadyCallback} that is invoked when the
* {@link GraphRequest} has been created and is ready to be executed.
*/
public static void newCurrentPlaceRequest(final CurrentPlaceRequestParams requestParams, final OnRequestReadyCallback callback) {
Location location = requestParams.getLocation();
CurrentPlaceRequestParams.ScanMode scanMode = requestParams.getScanMode();
LocationPackageRequestParams.Builder builder = new LocationPackageRequestParams.Builder();
// Don't scan for a location if one is provided.
builder.setLocationScanEnabled(location == null);
if (scanMode != null && scanMode == CurrentPlaceRequestParams.ScanMode.LOW_LATENCY) {
// In low-latency mode, avoid active Wi-Fi scanning which can takes
// several seconds.
builder.setWifiActiveScanAllowed(false);
}
LocationPackageManager.requestLocationPackage(builder.build(), new LocationPackageManager.Listener() {
@Override
public void onLocationPackage(LocationPackage locationPackage) {
if (locationPackage.locationError != null) {
callback.onLocationError(getLocationError(locationPackage.locationError));
} else {
Bundle parameters = getCurrentPlaceParameters(requestParams, locationPackage);
GraphRequest graphRequest = new GraphRequest(AccessToken.getCurrentAccessToken(), CURRENT_PLACE_RESULTS, parameters, HttpMethod.GET);
callback.onRequestReady(graphRequest);
}
}
});
}
Aggregations