General Android Integration Guide

Part I: Including DyScan in your Android Studio Project

  • This assumes that all developers’ GitHub usernames have been added to our repo and that they can access GitHub from their machines using an SSH key without providing a password (i.e. by using ssh-agent).
  • In the project-level build.gradle add a plugin (the plugins block must be immediately below the buildscript block)
  • plugins {
       id "" version "0.1"
  • Then in the app-level build.gradle add these dependencies:

  • dependencies {
        // Other dependencies are here
        implementation ''
        implementation ''
  • If you are using AndroidX, you will need implementation 'androidx.legacy:legacy-support-v13:1.0.0' as a dependency rather than'

Part II: General Guide

First, we need to import two 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) Then, add the method as:

public void onScanPress(View v) {
    Intent scanIntent = new Intent(this, DyScanActivity.class);

    scanIntent.putExtra("api-key", "{api_key_string}");

    // MY_SCAN_REQUEST_CODE (e.g., 1) is arbitrary and is only used within this activity.
    startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);

(Make sure to replace “{api_key_string}” with your API key from Dyneti) and replace MY_SCAN_REQUEST_CODE with the arbitrary value. Next, we'll override onActivityResult() to get the scan result.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);

   if (requestCode == 1) {
       if (data != null && data.hasExtra(DyScanActivity.EXTRA_SCAN_RESULT)) {
           CreditCard scanResult = data.getParcelableExtra(DyScanActivity.EXTRA_SCAN_RESULT);
           // Do stuff with results in scanResult 
  // Do stuff when no scan result is available.

The CreditCard class contains fields String cardNumber, int expiryMonth, int expiryYear, and boolean isFraud. Note that isFraud is currently always set to false.

Get Started