> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/classic-push-provisioning/ja/gaido/sdkno/android.md).

# Android

Push Provisioning SDK は、Google Pay と Samsung Pay 用にカードをトークン化するために使用されます。この SDK は、Google Pay および Samsung Pay SDK との通信を処理します。また、イシュアアプリケーション向けのトークン化フローも簡素化します。

このセクションは、Push Provisioning SDK をアプリケーションに統合したい Android のイシュアアプリケーション開発者向けです。

### 利用可能なサービス <a href="#available-services" id="available-services"></a>

Thales Push Provisioning SDK は、以下のサービスを提供します。

* イシュアアプリケーションを Push Provisioning SDK API と統合できるようにします。たとえば、 `isCardDigitized` および `addCard` （Google Pay と Samsung Pay）。
* Google Pay および Samsung Pay SDK を理解する必要性を減らします。
* 既存のプロジェクトで Push Provisioning SDK のサービスを再利用できます。
* FPAN を Google Pay または Samsung Pay に登録します。
* TSH サーバー API にアクセスします。

### 前提条件 <a href="#prerequisites" id="prerequisites"></a>

* Java バージョン: 11
* Android Studio バージョン: Chipmunk 以降。
* Google Play Services を搭載したデバイス（Google Pay 用）。

> <i class="fa-info-circle">:info-circle:</i>
>
> Google Pay の全機能を利用するには、モバイルデバイスで実行することを推奨します。

### イシュアアプリとの統合 <a href="#integrating-with-issuer-app" id="integrating-with-issuer-app"></a>

* という名前のフォルダを作成します `libs` を、次の図に示すようにモジュール（通常は「app」）ディレクトリ内に作成します。

<figure><img src="/files/bf329ba73e158cc5e5835508bd89a4fa346e4361" alt=""><figcaption></figcaption></figure>

* Push Provisioning SDK の AAR ファイルを `libs` フォルダにコピーします。
* Push Provisioning SDK v1.12.2 以降では、Samsung Pay SDK の JAR ファイルを  `libs` フォルダにコピーします。
* アプリの `build.gradle` または `build.gradle.kts` を開き、次の依存関係を追加します。

{% tabs %}
{% tab title="Groovy" %}

```groovy
android {
  defaultConfig {
    ndk {
      abiFilters 'arm64-v8a', 'x86_64', 'armeabi-v7a', 'x86'
    }
  }
  buildTypes {
        debug {
            // Samsung Pay 用
            manifestPlaceholders = [DEBUG_MODE: 'Y', SPAY_API_LEVEL: 2.22]
        }
        release {
            // Samsung Pay 用
            manifestPlaceholders = [DEBUG_MODE: 'N' , SPAY_API_LEVEL: 2.22]
        }
    }
}

dependencies {
    debugImplementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' // デバッグには logger が含まれます
    releaseImplementation 'com.squareup.okhttp3:okhttp:4.9.1'
    implementation "com.google.android.gms:play-services-base:18.5.0"
    implementation "com.google.android.gms:play-services-basement:18.5.0"
    implementation files('libs/tpcsdk.aar') // 最新の Push Provisioning SDK のファイル名を使用します 
    implementation files('lib/samsungpay_2.22.00.jar') // SDK v1.12.2 以降
    implementation 'net.java.dev.jna:jna:5.17.0@aar'
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
android {
  defaultConfig {
    ndk {
      abiFilters += listOf("arm64-v8a", "x86_64", "armeabi-v7a", "x86")
    }
  }
}

dependencies {
    debugImplementation ("com.squareup.okhttp3:logging-interceptor:4.9.1") // デバッグには logger が含まれます
    releaseImplementation ("com.squareup.okhttp3:okhttp:4.9.1")
    implementation ("com.google.android.gms:play-services-base:18.2.0")
    implementation (files("libs/tpcsdk.aar")) // 最新の Push Provisioning SDK のファイル名を使用します 
    implementation ("net.java.dev.jna:jna:5.17.0@aar")
}
```

{% endtab %}
{% endtabs %}

> <i class="fa-info-circle">:info-circle:</i>
>
> #### 注意 <a href="#note" id="note"></a>
>
> * Push Provisioning SDK V1.7.0 以降では、JNA ライブラリが依存関係として使用されます。Push Provisioning SDK で他のバージョンが動作する保証はないため、JNA V5.5.0 の使用を推奨します。
> * Push Provisioning SDK V1.12.0 以降では、16 KB ページサイズをサポートするために JNA V5.17.0 の使用が必須です。

* file-tree 依存関係を Gradle ビルドに取り込むには、アプリの `build.gradle` または `build.gradle.kts` を開き、次の依存関係を追加します。

{% tabs %}
{% tab title="Groovy" %}

```groovy
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
dependencies {
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
}
```

{% endtab %}
{% endtabs %}

* Push Provisioning SDK API の使用方法については、サンプルアプリと Java ドキュメントを参照してください。

> <i class="fa-exclamation-circle">:exclamation-circle:</i>
>
> #### 16 KB ページサイズのサポート <a href="#supporting-16-kb-page-sizesbr" id="supporting-16-kb-page-sizesbr"></a>
>
> 2025 年 11 月 1 日以降、Google Play に提出される新規開発アプリおよび既存アプリの更新で、Android 15 以降のデバイスを対象とするものは、16 KB ページサイズをサポートする必要があります。このサポートは Push Provisioning SDK V1.12.0 以降で利用できます。
>
> 16 KB ページサイズをサポートする APK をビルドする場合:
>
> * Push Provisioning SDK V1.12.0 以降にアップグレードします。
> * JNA 依存関係を 5.17.0 以降にアップグレードします。JNA 5.17.0 では、必要な Android Gradle Plugin (AGP) バージョンは 8.0.2 以降です。8.0.2 より前の AGP を使用している場合、コンパイルの問題が発生する可能性があります。
> * AGP のバージョンが 8.5.1 以降の場合、アプリは自動的に 16 KB ページサイズに合わせて調整されます。8.5.1 より前の場合は、 [レガシーのパッケージングオプションを](https://developer.android.com/guide/practices/page-sizes#agp_version_85_or_lower) で `build.gradle` ファイルに設定します。

### 構成 <a href="#configuration" id="configuration"></a>

次のスニペットを使用して、モバイルアプリケーションで Push Provisioning SDK を構成します。

> <i class="fa-info-circle">:info-circle:</i>
>
> #### 注意 <a href="#note-1" id="note-1"></a>
>
> Push Provisioning SDK V1.9.0 以降では、アプリケーションはアプリケーション `Context` の代わりに `Activity` を設定できます。これは Google Pay と Samsung Pay 用の Push Provisioning SDK を構成する場合です。 `Activity` 新しい API でのみ必要です。 `addCard(Activity activity, CardInfo cardInfo, TPCSDKListener<T> listener)`。Google Pay のプッシュプロビジョニング用です。

{% tabs %}
{% tab title="Java" %}

```java
protected static final int HTTP_TIMEOUT = 60;

protected CountDownLatch mCountDownLatch;

protected void awaitCountDownLatch() {
    try {
        mCountDownLatch.await(HTTP_TIMEOUT, TimeUnit.SECONDS);
    } catch (Exception e) { // 無視します。
    }
}

protected void resetCountDownLatch() {
    mCountDownLatch = new CountDownLatch(1);
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    Config config = new Config();
    config.setIssuerId("ISSUERID");
    config.setUrl("URL"); // 対応する URL
    
    // リストは必要に応じて更新できます。たとえば、OEMPayType を 1 種類だけにするだけでよい場合があります。
    List<OEMPayType> oemPayTypes = Arrays.asList(
        OEMPayType.NONE,
        OEMPayType.GOOGLE_PAY,
        OEMPayType.SAMSUNG_PAY,
        OEMPayType.HUAWEI_PAY);

    for (OEMPayType oemPayType:oemPayTypes) {
        if (oemPayType == OEMPayType.SAMSUNG_PAY) {
            config.setContext(getApplicationContext());
            config.setServiceId("SERVICEID");
            config.setVisaClientAppId("VisaClientAppID");
        } else if (oemPayType == OEMPayType.HUAWEI_PAY) {
            String callbackUrl = "tpcsdk://com.thalesgroup.tpc.demo/tokenRequestorsPage";
            config.setCallbackUrl(callbackUrl);
            config.setActivity(getActivity());
        } else if (oemPayType == OEMPayType.GOOGLE_PAY) {
            //Push Provisioning SDK V1.9.0 以降、Google Pay 用の Push Provisioning SDK 構成時に、アプリケーションは `Activity` の代わりに `Context` を設定できます
            config.setContext(getApplicationContext());
        } else if (oemPayType == OEMPayType.NONE) {
            //Push Provisioning SDK V1.9.0 以降、Scheme Provisioning 用の Push Provisioning SDK 構成時に、アプリケーションは `Activity` の代わりに `Context` を設定できます
            config.setContext(getApplicationContext());
        }
        configSdk(oemPayType, config);
    }
}

public void configSdk(OEMPayType oemPayType, Config configs) throws InterruptedException {
    // シェームへのプッシュ用
    configs.setOemPayType(oemPayType);
    resetCountDownLatch();
    TPCManager.getInstance().config(configs, new TPCSDKListener<Boolean>() {
        @Override
        public void onStart() {
        }

        @Override
        public void onSuccess(TPCResult<Boolean> result) {
            Log.d("CONFIG_SDK", "Configuration successful..." + oemPayType.getOemType());
            mCountDownLatch.countDown();
        }

        @Override
        public void onError(TPCSDKException exception) {
            Log.e("CONFIG_SDK", "Configuration setup failed with error: " + exception.getMessage());
            mCountDownLatch.countDown();
        }
    });
    awaitCountDownLatch();
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
class MainViewModel : ViewModel() {
    fun configureMultipleOEM(activity: Activity){
        viewModelScope.launch {
            val config = Config()
            config.issuerId = "ISSUERID"
            config.url = "URL" // 対応する URL

            // リストは必要に応じて更新できます。たとえば、OEMPayType を 1 種類だけにするだけでよい場合があります。
            val oemPayTypes: List<OEMPayType> = listOf(
                OEMPayType.NONE,
                OEMPayType.GOOGLE_PAY,
                OEMPayType.SAMSUNG_PAY,
                OEMPayType.HUAWEI_PAY
            )
            for (oemPayType in oemPayTypes) {
                when (oemPayType) {
                    OEMPayType.SAMSUNG_PAY -> {
                        config.serviceId = "SERVICEID"
                        config.context = applicationContext
                        config.visaClientAppId = "VisaClientAppID";
                    }
                    OEMPayType.HUAWEI_PAY -> {
                        val callbackUrl = "tpcsdk://com.thalesgroup.tpc.demo/tokenRequestorsPage"
                        config.callbackUrl = callbackUrl
                        config.activity = activity
                    }
                    OEMPayType.GOOGLE_PAY -> {
                        //Push Provisioning SDK V1.9.0 以降、Google Pay 用の Push Provisioning SDK 構成時に、アプリケーションは `Activity` の代わりに `Context` を設定できます
                        config.context = applicationContext
                    }
                    OEMPayType.NONE -> {
                        //Push Provisioning SDK V1.9.0 以降、Scheme Provisioning 用の Push Provisioning SDK 構成時に、アプリケーションは `Activity` の代わりに `Context` を設定できます
                        config.context = applicationContext
                    }
                }
                configSdk(oemPayType, config).collect{
                    println(it)
                }
            }
        }
    }

    private fun configSdk(oemPayType: OEMPayType, configs: Config): Flow<TPCResult<Boolean>> =  callbackFlow {
        val callBack = object : TPCSDKListener<Boolean?> {
            override fun onStart() {}
            override fun onSuccess(result: TPCResult<Boolean?>) {
                Log.d("CONFIG_SDK", "Configuration successful..." + oemPayType.oemType)
                channel.close()
            }

            override fun onError(exception: TPCSDKException) {
                Log.e("CONFIG_SDK", "Configuration setup failed with error: " + exception.message)
                channel.close()

            }
        }
        TPCManager.getInstance().config(configs, callBack)
        
    }
}
```

{% endtab %}
{% endtabs %}

#### Samsung Pay の構成 <a href="#samsung-pay-configurations" id="samsung-pay-configurations"></a>

Android R（target SDK 30）以降では、 `<queries>` を Android マニフェストファイルに宣言する必要があります。

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" 
  package="xxx.xxx.xxx.xxx">
  
  <application>
    <!-- Samsung Pay 用 -->
    <meta-data
      android:name="debug_mode"
      android:value="${DEBUG_MODE}" />
    <!-- Samsung Pay 用 -->
    <meta-data
      android:name="spay_sdk_api_level"
      android:value="${SPAY_API_LEVEL}" />
  </application>
  
  <queries>
    <package android:name="com.samsung.android.spay" />
    <package android:name="com.samsung.android.samsungpay.gear" />
  </queries>
```

### 難読化 <a href="#obfuscation" id="obfuscation"></a>

アプリで Samsung Pay に関する ProGuard の問題がある場合は、次のルールを使用してください。

```
# Samsung Pay
-keep class com.samsung.android.sdk.** { *; }
-keep interface com.samsung.android.sdk.** { *; }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/classic-push-provisioning/ja/gaido/sdkno/android.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
