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.
16 KB Page Size Support
Certain newer Android devices will begin using 16 KB page size. Dyneti has released version 1.7.14
which supports these devices.
To upgrade:
Change your implementation directive to use 1.7.14
Gradle version 8.10
is required to build with support for 16 KB page size. Make sure the distributionUrl
in gradle-wrapper.properties
points to the correct version.
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.
If you want to have more control over the experience than DyScanActivity provides, we also offer a DyScanView.
Last updated