# Using the Mastercard Connect Android SDK
source: https://developer.mastercard.com/open-finance-au/documentation/connect/integrating-with-connect/android/android-sdk/index.md

The Mastercard Connect Android SDK is distributed as a compiled binary in Maven Central which allows you to easily integrate our SDK into your development projects.

Maven central is Android's officially supported format for distributing binary libraries to multiple platforms and architectures in a single bundle.
Note: Chase bank (JPMorgan Chase) has removed support for certain types of WebView traffic. This will impact the Chase OAuth flow if your SDK integration is not using the most recent version of our SDKs. The latest version will support secure web containers, e.g., Custom Tabs. For more information see the [Chase Developer documentation](https://developer.chase.com/products/aggregation-consent/guides/launching-the-oauth-flow-in-a-secure-container/) Warning: The Connect Android SDK does not support the Connect Transfer flow (for Deposit Switch and Bill Pay Switch). We provide a separate Connect Transfer Android SDK for this purpose.

## Compatibility {#compatibility}

* Android 5.0 (Lollipop) or later, Android SDK level 21 or later:

  Warning: Support for deepLinkUrl parameters is deprecated from version 3.0.0 of the Connect Android SDK. Going forward you should use the `redirectUrl` parameter, which supports both universal and deep links. See our [Github changelog entry](https://github.com/Mastercard/connect-android-sdk/blob/main/CHANGELOG.md#300-august-10-2023).
* Android 15 or later, Android SDK level 35 or later:

  Note: Starting from version 3.0.6, the Connect Android SDK will handle the redirect internally via a fallback mechanism if you do not specify a `redirectUrl` via the SDK or a `redirectUri` from [Generate Connect URL](https://developer.mastercard.com/open-finance-au/documentation/connect/generate-2-connect-url-apis/index.md) (this fixes a problem seen on Android 15+ where the OAuth popup might not dismiss automatically). See our [Github changelog entry](https://github.com/Mastercard/connect-android-sdk/blob/main/CHANGELOG.md#306-october-7-2025).

  <br />

## Install the Connect Android SDK {#install-the-connect-android-sdk}

Install the Connect Android SDK using Maven Central or manually from GitHub.

### Maven Central {#maven-central}

Modify your root-level Gradle file (`build.gradle`) as follows:

```gradle
allprojects {
   repositories {
       google()
       mavenCentral()
   }
}
```

Modify your app-level Gradle file (`build.gradle`) as follows:

```html
android {
 defaultConfig {
   minSdkVersion 21 // or greater
 }
}
dependencies {
 // ...
 implementation 'com.mastercard.openbanking.connect:connect-sdk:<insert latest version>'
}
```

**Note** : The latest version of the Connect Android SDK can be found in [Maven Central](https://central.sonatype.com/artifact/com.mastercard.openbanking.connect/connect-sdk/2.3.0/versions).

### Manual Install {#manual-install}

Import the `connect-sdk` module into your project as follows:

1. Clone the Connect Android SDK from [Github](https://github.com/Mastercard/connect-android-sdk)

2. On your Android project, click on **File** \> **New** \> **Import Module** , select the folder you cloned the Connect Android SDK into, then click **Finish**.

3. Modify the [build.gradle](https://github.com/Mastercard/connect-android-sdk/blob/main/connect-sdk/build.gradle) file in the `connect-sdk` module to remove the following lines:

    apply from: "$project.rootDir/sonar.gradle"
    apply from: "${rootProject.projectDir}/sonatype-publish.gradle"

4. Clean and build the project.

## Update Android application settings {#update-android-application-settings}

The Connect Android SDK requires internet access to connect with our servers, so you need to add internet permissions to the `AndroidManifest.xml` file:

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

#### App Link Support {#app-link-support}

Add the following activity to the **AndroidManifest.xml** file.

```html
<activity android:name="com.mastercard.openbanking.connect.Connect"   
 android:launchMode="singleTask"    
 android:exported="true">
 <intent-filter>        
    <action android:name="android.intent.action.VIEW" />        
    <category android:name="android.intent.category.DEFAULT" />        
    <category android:name="android.intent.category.BROWSABLE" />        
     <data
        android:scheme="https"
        android:host="{{example.com}}"/>
 </intent-filter>
 </activity>
```

#### Deep Link Support {#deep-link-support}

Add the following activity to the **AndroidManifest.xml** file.

```html
<activity android:name="com.mastercard.openbanking.connect.Connect"   
 android:launchMode="singleTask"    
 android:exported="true">
 <intent-filter>        
    <action android:name="android.intent.action.VIEW" />        
    <category android:name="android.intent.category.DEFAULT" />        
    <category android:name="android.intent.category.BROWSABLE" />        
    <data android:scheme="{deep_link_app_name}"/>    
 </intent-filter>
 </activity>
```

Note: `{deep_link_app_name}` is case sensitive and should only use lower-case characters.

## Add code to start the Connect Android SDK {#add-code-to-start-the-connect-android-sdk}

### Connect Class {#connect-class}

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.

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. To access the APIs in the SDK include the following imports:

```Java
  import com.mastercard.openbanking.connect.Connect;
  import com.mastercard.openbanking.connect.EventHandler;
```

**App Link Support**

```Java
Connect.start(this, url, "https://example.com/connect", eventHandler);
```

**Deep Link Support**

```Java
Connect.start(this, url, "{deep_link_app_name}://", eventHandler);
```

* Java
* Kotlin

```java
public static void start(Context context, String connectUrl, String redirectUrl, EventHandler eventHandler)
```

```kotlin
fun start(context: Context, connectUrl: String?, redirectUrl: String?, eventHandler: EventHandler?)
```

#### Parameters {#parameters}

|       Parameter       |                              Description                              |
|-----------------------|-----------------------------------------------------------------------|
| context (required)    | The Android Context is referenced by Connect when an activity starts. |
| connectUrl (required) | The SDK loads the Connect URL.                                        |

\| eventHandler (required) \| A class implementing the EventHandler interface. \|

### 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.
* Java
* Kotlin

```java
public interface EventHandler {
    void onLoaded();
    void onDone(JSONObject doneEvent);
    void onCancel(JSONObject cancelEvent);
    void onError(JSONObject errorEvent);
    void onRouteEvent(JSONObject routeEvent);
    void onUserEvent(JSONObject userEvent);
}
```

```kotlin
interface EventHandler {
    fun onLoaded()
    fun onDone(doneEvent: JSONObject?)
    fun onCancel(cancelEvent JSONObject?)
    fun onError(errorEvent: JSONObject?)
    fun onRouteEvent(routeEvent: JSONObject?)
    fun onUserEvent(userEvent: JSONObject?)
}
```

#### Callback Events {#callback-events}

See [here](https://developer.mastercard.com/open-finance-au/documentation/connect/integrating-with-connect/index.md#callback-events) for details on the events via their callback interface.

**Note** : The onDone, onError, onRoute, and onUser callback functions will have a **JSONObject** parameter that contains data about the event.
