Address Screen

The address screen allows the user to select an address. This screen plugs into the address API on the Karhoo exchange. For each session, the last 5 searches are cached for the users. When the preferences are cleared for the application, these cached addresses will also be removed.

From the booking screen, the user can select a pickup point, a destination and a booking time ("ASAP" if left blank). They will then receive a list of quotes and be able to select one to book.

In the UI SDK, the address screen is launched from the booking screen when the user selects either the pickup or drop-off input field in the address bar. The user is able to select an address by:

  • typing in an address - auto-complete is activated as soon as 3 letters are entered in an address search field
  • Selecting a recent address (if these are available)
  • Selecting the user's current location
  • Setting a location on the map view

To launch the address screen, create the Intent and using the AddressActivity builder and set the address type i.e. whether it is pickup or drop off and call startActivityForResult().

Additional parameters need to be passed into the builder:

  • addressType: AddressType - The activity will use the addressType to display in its UI whether the user is searching for their pickup or destination. Possible options are AddressType.PICKUP and AddressType.DESTINATION
  • locationBias: (latitude: Double, longitude: Double) - Passes up the latitude and longitude with the address search to help locate the address. The UI SDK’s BookingActivity will supply the latitude and longitude of the current pickup point.
val addressType: AddressType = AddressType.PICKUP//Or AddressType.DESTINATION 
val addressCode: AddressCodes = AddressCodes.PICKUP//Or AddressCodes.DESTINATION
val latitude: Double = //Set based on the user's location 
val longitude: Double = //Set based on the user's location
 
val intent = AddressActivity.Builder.builder
        .addressType(addressType)
            .locationBias(latitude, longitude)
        .build(context)
startActivityForResult(intent, addressCode)

The pickup and drop off result data can be retrieved in onActivityResult()

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    //Check AddressCodes.DESTINATION to get the destination information
    if (resultCode == RESULT_OK && requestCode == AddressCodes.PICKUP) {
        val pickup = data?.getParcelableExtra<LocationInfo>(AddressCodes.DATA_ADDRESS)
    }
    super.onActivityResult(requestCode, resultCode, data)
}

What’s Next