> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

This article describes how to set up the Payment Links SDK for Android.

## Requirements

|                      |        |
| -------------------- | ------ |
| Minimum target level | **24** |

## Step 1 | Import the SDK

To import the Android Payment Links SDK, add the following implementation to your `build.gradle` file:

```js theme={"system"}
implementation("com.appcharge:android-payment-links:1.6.0")
```

Then add the following to your `settings.gradle` file:

```js theme={"system"}
repositories {
    mavenCentral()
}
```

## Step 2 | Add Permissions

In the Manifest file, add the necessary permissions to access the network state and enable incoming deeplink over HTTPS:

<CodeGroup>
  ```xml xml theme={"system"}
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <queries>
          <intent>
              <action android:name="android.intent.action.VIEW" />
              <data android:scheme="https" />
          </intent>
  </queries>
  ```
</CodeGroup>

## Step 3 | Configure a URL Scheme

Next, add support for checkout activity and deeplink scheme:

<CodeGroup>
  ```xml xml theme={"system"}
   <activity
      android:name="com.appcharge.paymentlinks.CheckoutActivity"
  		android:configChanges="orientation|screenSize"
      android:screenOrientation="unspecified"
      android:exported="true"
      android:launchMode="singleTask"
      tools:ignore="DiscouragedApi">
      <!-- Custom scheme -->
      <intent-filter android:autoVerify="true">
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="acnative-{IDENTIFIER}"/>
          <data android:host="action"/>
          <data android:scheme="https"/>
      </intent-filter>
  </activity>
  ```
</CodeGroup>

<Warning>
  The **`intent-filter`** includes a scheme **`"acnative-{IDENTIFIER}"`**. Change the **\{IDENTIFIER}** to the last sequence of your package name. For example, if your package name is **`com.appcharge.mysupergame`**, the identifier will be **`mysupergame`**.

  This name must be lowercase with no spaces, according to the [Android code style guide](https://source.android.com/docs/core/architecture/hidl/code-style).
</Warning>

## Step 4 | Set up foreground service for your checkout (Optional)

To improve checkout stability, you can enable a foreground service. This keeps your app prioritized while the checkout is open, helping prevent Android from closing or deprioritizing it during payment and network operations.

To set up the checkout service:

1. Add the following permissions to your `AndroidManifest.xml` file:

<CodeGroup>
  ```xml xml theme={"system"}
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  ```
</CodeGroup>

2. Then register the service inside the `<application>` tag. When this service is enabled, Android may display a notification from your game while the checkout is open. To make sure the notification uses your game name instead of the package name, set `android:label` on the `<application>` tag:

<CodeGroup>
  ```xml xml theme={"system"}
  <application android:label="APP_NAME">
    <!-- android:label is optional. -->
    <service android:name="com.appcharge.paymentlinks.CheckoutService" 
      android:exported="false" 
      android:foregroundServiceType="shortService" />  
  </application>
  ```
</CodeGroup>

<Note> If you're upgrading an existing integration that already includes the `CheckoutService` declaration, update `android:foregroundServiceType` from `dataSync` to `shortService` in your manifest. </Note>

3. After SDK initialization or before launching checkout, enable or disable the service in code:

<CodeGroup>
  ```kotlin Kotlin theme={"system"}
  BridgeAPI.setCheckoutServiceMode(true) // Enable
  BridgeAPI.setCheckoutServiceMode(false) // Disable
  ```
</CodeGroup>

<Note> By default, `setCheckoutServiceMode` is enabled. If you don't want to use the checkout service, remove the related permissions and the `CheckoutService` declaration from your manifest file, or disable it using the SDK Bridge method above. </Note>
