Enabling Device Enrollment {#ttp-device-enroll-intro}
=====================================================

Use this information to enable device enrollment and view the device enrollment result in the Tap to Pay on Android SDK. The enrollment workflow guides you through the device enrollment activity.

Enroll a Device {#ttp-device-enroll-device}
===========================================

Before starting the device enrollment process, make sure the Tap to Pay Ready app is installed on the Android device. Download the app using this [Google Play Store link](https://play.google.com/store/apps/details?id=com.visa.kic.app.kernel ""). If the app is not installed before device enrollment, you will be prompted to install it during the enrollment process. To learn more about the Tap to Pay Ready app, see [PCI MPoC Standard Compliance](/docs/cybs/en-us/tap-to-phone/integration/all/rest/tap-to-phone/tap-to-phone-intro/ttp-comply-pci-mpoc-intro.md "").  
Use the information in this section to enroll a device using the `enrollDevice` activity. This activity presents a merchant-facing UI that enables users to enroll a new device or a previously enrolled device by selecting or entering the device's serial number. Follow this step to enroll a device.

1. Use the `enrollDevice` activity to enroll the device.

   ```
   val mposUi: MposUi = ...
   mposUi.tapToPhone.enrollDevice(activity, requestCode)
   ...
   override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
       super.onActivityResult(requestCode, resultCode, data)

       val isEnrollmentSuccessful =
           resultCode == EnrollResultIntent.ENROLLMENT_RESULT_CODE &&
           data?.getStringExtra(EnrollResultIntent.ENROLLMENT_RESULT_EXTRA) ==
               EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_ENROLLED

       if (isEnrollmentSuccessful) {
           val serialNumber = data?.getStringExtra(
               EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_SERIAL_NUMBER
           )
           onEnrollmentComplete(serialNumber)
       } else {
           onEnrollmentFailed()
       }
   }
   ```

   #### Step Result

The `enroll` activity returns the result Intent.

Enroll a Previously Enrolled Device {#ttp-device-enroll-prev-device}
====================================================================

Use this information to enroll a previously enrolled device by using the `reEnrollDevice` activity. This activity enables you to perform device re-enrollment through the SDK by supplying a stored serial number. This streamlined workflow eliminates the need for the merchant to manually select or enter the serial number during re-enrollment.

1. Use the `reEnrollDevice` activity to enroll the previously enrolled device.

   ```
   val mposUi: MposUi = ...
   mposUi.tapToPhone.reEnrollDevice(activity, serialNumber, requestCode)
   ...
   override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
       super.onActivityResult(requestCode, resultCode, data)

       val isEnrollmentSuccessful =
           resultCode == EnrollResultIntent.ENROLLMENT_RESULT_CODE &&
           data?.getStringExtra(EnrollResultIntent.ENROLLMENT_RESULT_EXTRA) ==
               EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_ENROLLED

       if (isEnrollmentSuccessful) {
           val serialNumber = data?.getStringExtra(
               EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_SERIAL_NUMBER
           )
           onEnrollmentComplete(serialNumber)
       } else {
           onEnrollmentFailed()
       }
   }
   ```

   #### Step Result

The `enroll` activity returns the result `Intent`.

View the Device Enrollment Result {#ttp-device-enroll-view-result}
==================================================================

After completing device enrollment, use the `enroll` activity or `isDeviceEnrolled` function to view the device enrollment result.  
The `enroll` activity returns the result `Intent` when the device enrollment process is successful. This example shows the information that is returned in the result `Intent`:

```
RESULT_CODE: EnrollResultIntent.ENROLLMENT_RESULT_CODE (3489523)
EXTRA: EnrollResultIntent.ENROLLMENT_RESULT_EXTRA (enrollmentResult)
EXTRA: EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_ENROLLED (deviceEnrolled)
EXTRA: EnrollResultIntent.ENROLLMENT_RESULT_EXTRA_SERIAL_NUMBER (serialNumber)
```

{#ttp-device-enroll-view-result_codeblock_z2v_5xg_ndc}  
The `isDeviceEnrolled` function returns a `true` value when the device is enrolled or a `false` value when not. This example shows how to use the function:

```
val isEnrolled = mposUi.tapToPhone.isDeviceEnrolled()
```

