Connect Android SDK

The Connect Android SDK allows you to embed Finicity Connect anywhere you want within your own mobile applications.


Compatability

The Connect Android SDK supports the following Android versions.

  • Android 5.0 (Lollipop) or later
  • minSdkVersion 21 or later

Step 1— Add the SDK dependency to your project

JCenter support

Get the latest Connect Android SDK through JCenter support and integrate it into your Android project.

a.  Add the following code to the dependency section in the build.gradle file.

 

 

 dependencies {
implementation 'com.finicity.connect:connect-sdk:+'
}

b.  To ensure you get the library, add JCenter as a repository in your build.gradle file.

 allprojects {
repositories {
google()
jcenter()

}
}

 c.  To access the APIs in the SDK, import the following source files. 

 

   Import com.fnicity.connect.sdk;
  Import com.fnicity. connect.sdk.EventHandler;

SDK Specific Versions

If you want a specific SDK version, modify the line of code. Replace the plus sign (+) with the version number.

 Example: To get Connect Android SDK v1.0.4, modify the plus (+) sign to specify the version.

 

Before
  dependencies {
implementation 'com.finicity.connect:connect-sdk:+'
}
After
 dependencies {
implementation 'com.finicity.connect:connect-sdk:1.0.4'
}

Manually Download the SDK

Manually download the SDK from the Finicity Developer Portal.

Connect-sdk-v1.0.4.aar (sha256)

  1. Add the SDK library to your Android project. See adding your library as a dependency
  2. Open the gradle.properties file and set android.enableJetifier to true.

See Migrating to AndroidX

Step 2—Update Android application settings

Add internet permissions to the AndroidManifest.xml file.

Sample
 <uses-permission android:name="android.permission.INTERNET"> 

Step 3—Add code to start the Connect SDK

The Connect class contains a start method that when called, starts an activity with the supplied event listener. The SDK only allows a single instance of the Connect activity to run. If you start Connect while a Connect activity is already running, a RuntimeException is thrown.

Connect Class

The Connect Android SDK’s main component is the Connect class that contains a static start method, which runs an activity that connects with the EventHandler.

Sample
 public static void start(Context context, String connectUrl, EventHandler eventHandler) 
Sample
 fun start(context: Context, connectUrl: String?, eventHandler: EventHandler?) 
Argument
contextThe Android Context is referenced by Connect when an activity starts.
connectUrlThe SDK loads the Connect URL.

eventHandler
A class implementing the EventHandler interface.

EventHandler Interface

Throughout Connect’s flow events about the state of the web application are sent as JSONObjects to the EventHandler methods.

The onUserEvent handler will not return anything unless you’re specifically targeting Connect 2.0.

Sample
 public interface EventHandler {
void onLoaded();
void onDone(JSONObject doneEvent);
void onCancel();
void onError(JSONObject errorEvent);
void onRouteEvent(JSONObject routeEvent);
void onUserEvent(JSONObject userEvent);
}
Sample
 interface EventHandler {
fun onLoaded()
fun onDone(doneEvent: JSONObject?)
fun onCancel()
fun onError(errorEvent: JSONObject?)
fun onRouteEvent(routeEvent: JSONObject?)
fun onUserEvent(userEvent: JSONObject?)
}
Events
loadedSent when the Connect web page is loaded and ready to display.
doneSent when the user successfully completes the Connect appliction.
cancelSent when the user cancels the Connect application.
errorSent when there is an error during the Connect application.
routeSent when the user navigates to a new route or screen in Connect.
userSent when user events occur in Connect.

Manually Stop a Connect Activity

The Connect activity will automatically finish on done, cancel, and error events.

You can manually finish a Connect activity by invoking:  

Sample
 Connect.finishCurrentActivity() 

If there isn’t a current Connect activity running, then the method will throw a RuntimeException.

Process Restarts

Android sometimes stops your application’s process and restarts it when your application is refocused. If this happens, the Connect activity automatically finishes when the application resumes. If you want Connect to run again, call the start method. See Connect Class.