当前位置: 首页>>代码示例>>Java>>正文


Java RideRequestButton类代码示例

本文整理汇总了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();
}
 
开发者ID:uber,项目名称:rides-android-sdk,代码行数:43,代码来源:SampleActivity.java


注:本文中的com.uber.sdk.android.rides.RideRequestButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。