本文整理汇总了Java中com.uber.sdk.android.rides.RideRequestButton类的典型用法代码示例。如果您正苦于以下问题:Java RideRequestButton类的具体用法?Java RideRequestButton怎么用?Java RideRequestButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RideRequestButton类属于com.uber.sdk.android.rides包,在下文中一共展示了RideRequestButton类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.uber.sdk.android.rides.RideRequestButton; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
configuration = new SessionConfiguration.Builder()
.setRedirectUri(REDIRECT_URI)
.setClientId(CLIENT_ID)
.setServerToken(SERVER_TOKEN)
.build();
validateConfiguration(configuration);
ServerTokenSession session = new ServerTokenSession(configuration);
RideParameters rideParametersForProduct = new RideParameters.Builder()
.setProductId(UBERX_PRODUCT_ID)
.setPickupLocation(PICKUP_LAT, PICKUP_LONG, PICKUP_NICK, PICKUP_ADDR)
.setDropoffLocation(DROPOFF_LAT, DROPOFF_LONG, DROPOFF_NICK, DROPOFF_ADDR)
.build();
// This button demonstrates deep-linking to the Uber app (default button behavior).
blackButton = (RideRequestButton) findViewById(R.id.uber_button_black);
blackButton.setRideParameters(rideParametersForProduct);
blackButton.setSession(session);
blackButton.setCallback(this);
blackButton.loadRideInformation();
RideParameters rideParametersCheapestProduct = new RideParameters.Builder()
.setPickupLocation(PICKUP_LAT, PICKUP_LONG, PICKUP_NICK, PICKUP_ADDR)
.setDropoffLocation(DROPOFF_LAT, DROPOFF_LONG, DROPOFF_NICK, DROPOFF_ADDR)
.build();
// This button demonstrates launching the RideRequestActivity (customized button behavior).
// You can optionally setRideParameters for pre-filled pickup and dropoff locations.
RideRequestButton uberButtonWhite = (RideRequestButton) findViewById(R.id.uber_button_white);
RideRequestActivityBehavior rideRequestActivityBehavior = new RideRequestActivityBehavior(this,
WIDGET_REQUEST_CODE, configuration);
uberButtonWhite.setRequestBehavior(rideRequestActivityBehavior);
uberButtonWhite.setRideParameters(rideParametersForProduct);
uberButtonWhite.setSession(session);
uberButtonWhite.loadRideInformation();
}