Android Integration Guide
Importing DyScan
The easiest way to integrate DyScan is by using our Nexus repository, which is covered in this guide.
If you would rather include DyScan directly as a library, see the instructions here.
In the project-level build.gradle
add the Dyneti Maven repository (credentials provided during integration):
Default DyScan configuration includes the TensorFlow library. Since version 1.2.0, you can exclude it from DyScan if you prefer to use your own build of TensorFlow.
In the app-level build.gradle
add the dependency:
If you would rather integrate without using our Nexus repository, see Manually Importing the Library.
If you encounter the following error while building your project
Add the following dependency to your app-level build.gradle:
Initializing DyScan (only for version 1.1.0 and up)
In your Application
class add the following line to init DyScan
.
Camera features support
By default, DyScan uses uses-feature
tags in its AndroidManifest.xml
file to filter out devices that don't support the required camera features. This filtering affects the host app's supported device count in Google Play.
You can override this filtering by adding the below lines into your AndroidManifest.xml
manifest tag section:
If you choose to override the default tags settings inAndroidManifest.xml,
you should additionally check manually if the device is supported before calling DyScan functions to avoid a bad user experience (see below).
Interfacing DyScan
If your app already has card.io, see the migrating from card.io guide.
Import the following DyScan classes in your Activity that will launch DyScan:
This example assumes that you're going to launch the scanner from a button, and that you've set the button's onClick
handler in the layout XML via android:onClick="onScanPress"
. (If not, the process is analogous, just use the code inside this function). onScanPress
is implemented as
Next, override onActivityResult()
to get the scan result.
If you are using Stripe, see this guide for how to implement these functions.
The CreditCard
class contains fields String cardNumber
, int expiryMonth
, int expiryYear
, boolean isFraud,
and String cardOrientation
. For the OCR-only version of DyScan, isFraud
is always set to false, and expiryYear
is the full four-digit year.
Customizing DyScanActivity
The DyScanActivity can be customized by passing EXTRAs along with the intent. This allows you to modify both the appearance and behavior of the Activity.
EXTRA | Description | Default Value |
| What to text to display to the user to guide them in scanning their card. It is highly recommended that you set this value; otherwise we will try to provide this text based on | Dependent on |
| The color to use to display the helper text. |
|
| The size of the helper text in |
|
| The font family name of the helper text. The font needs to be placed in assets first. | Default font |
| The position of the helper text. DyScanHelperTextPosition enum values: TOP, CENTER, BOTTOM | DyScanHelperTextPosition.BOTTOM |
| Whether to show the helper text on screen. |
|
| Whether to show the scan area outline |
|
| How thick to make the lines outlining the scan area, indicating to the user where to place their credit card. Input as a float. |
|
| The color to use in drawing the outline of the scan region when nothing of interest is detected. |
|
| The color to use in drawing the outline of the scan region when corners are detected. |
|
| The color to use in drawing the outline of the scan region when we have successfully scanned a card. |
|
| The color to use to obscure everything outside the scan region in order to draw the user’s attention to the scan region. |
|
| The opacity to use when obscuring everything outside the scan region, as an integer ranging from 0 (transparent) to 255 (opaque). |
|
| Whether to show the button which allows the user to rotate the scan region by 90 degrees, facilitating the scanning of vertical cards. |
|
| Whether to show a button at the bottom of the screen allowing the user to choose to exit the scanning Activity. |
|
| The String to display on the manual entry button if shown. This should be set if you are showing the manual entry button. | |
| Whether to briefly show the scanned card number (and date, if present) as an overlay over the screen after a successful scan. |
|
| Whether to display number on completion horizontally in fixed position. |
|
| Whether to show a dark blue Dyneti logo and wordmark above the scan region. |
|
| Whether to show the overlay displaying a sample card number and expiration date hinting at the user to place their card in the scan region. |
|
| If | The default locale's language according to the device |
| Whether the phone will turn on the flashlight if multiple frames have appeared to be too dark. If set to false, torch toggle button will appear. |
|
| Whether the device will vibrate once it has successfully extracted the credit card data from the images provided by the camera. |
|
| The content description of card scan frame. |
|
| Whether DyScanActivity is being used as a fraud check. This is currently only used for logging purposes, but in the future may impact behavior. |
|
| Whether to allow cards to scan in sideways orientation. If set to true, vertical cards will be able to be scanned when positioned in the horizontal scan window. Note that EXTRA_SIDEWAYS_SCANNING_ENABLED and EXTRA_SHOW_ROTATE_BUTTON should not simultaneously be set to true. |
|
If you want to have more control over the experience than DyScanActivity provides, we also offer a DyScanView.
Last updated