我按照Uber的Ride请求按钮将如何为Android应用程序提供示例。一切都没问题,直到我想显示我想要的目的地的时间估计和价格。
这是我的代码:
//setting the uber config
private void setupUberConfig() {
uberSessionConfig = new SessionConfiguration.Builder()
.setClientId(getString(R.string.uber_client_id))
.setServerToken(getString(R.string.uber_server_token))
.setClientSecret(getString(R.string.uber_client_secret))
.setRedirectUri("http://www.upnixt.com")
.setScopes(Arrays.asList(Scope.RIDE_WIDGETS, Scope.REQUEST))
.setEnvironment(SessionConfiguration.Environment.SANDBOX)
.build();
UberSdk.initialize(uberSessionConfig);
}
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... voids) {
return currentPlace.getUberXProductId(mContext, MainActivity.getCurrentLocationForOthers().getLatitude(), MainActivity.getCurrentLocationForOthers().getLongitude(),
getString(R.string.uber_server_token));
}
@Override
protected void onPostExecute(String productId) {
super.onPostExecute(productId);
callUber.setVisibility(View.VISIBLE);
RideParameters rideParams;
if (productId != null) {
rideParams = new RideParameters.Builder()
.setProductId(productId)
.setPickupLocation(MainActivity.getCurrentLocationForOthers().getLatitude(), MainActivity.getCurrentLocationForOthers().getLongitude(), "", "")
.setDropoffLocation(currentPlace.getLat(), currentPlace.getLng(), currentPlace.getName(), currentPlace.getAddress())
.build();
} else {
rideParams = new RideParameters.Builder()
.setPickupLocation(MainActivity.getCurrentLocationForOthers().getLatitude(), MainActivity.getCurrentLocationForOthers().getLongitude(), "", "")
.setDropoffLocation(currentPlace.getLat(), currentPlace.getLng(), currentPlace.getName(), currentPlace.getAddress())
.build();
}
callUber.setRideParameters(rideParams);
ServerTokenSession session = new ServerTokenSession(uberSessionConfig);
callUber.setSession(session);
callUber.setCallback(new RideRequestButtonCallback() {
@Override
public void onRideInformationLoaded() {
Log.d("SELLE", "Info Loaded");
}
@Override
public void onError(ApiError apiError) {
Log.d("SELLE", apiError.getClientErrors().get(0).getTitle());
}
@Override
public void onError(Throwable throwable) {
Log.d("SELLE", "Info Loaded");
}
});
callUber.loadRideInformation();
}
}.execute();
我从Uber的v1 / products API获得了产品ID。 我错过了什么?