5

NFC HCE アプリケーションで NFC タップ アンド ペイの設定に表示されるように調整する重要な点は何ですか?

次のコードはアプリに対して true を返すため、支払いが可能です。

boolean isDefault = CardEmulation
                .getInstance(NfcAdapter.getDefaultAdapter(this))
                .isDefaultServiceForCategory(
                        new ComponentName(this, MyPaymentService.class),
                        CardEmulation.CATEGORY_PAYMENT);

マニフェストのサービス宣言:

<service
    android:name="my.package.MyPaymentService"
    android:exported="true"
    android:permission="android.permission.BIND_NFC_SERVICE" >
    <intent-filter>
        <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

    <meta-data
        android:name="android.nfc.cardemulation.host_apdu_service"
        android:resource="@xml/apduservice" />
</service>

apduservice:

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:requireDeviceUnlock="true" >

    <aid-group
        android:category="payment"
        android:description="@string/paymentGroup" >
        <aid-filter
            android:name="325041592E5359532E4444463031"
            android:description="@string/ppse" />
        <aid-filter
            android:name="A0000000041010"
            android:description="@string/mastercard" />
        <aid-filter
            android:name="A0000000031010"
            android:description="@string/visa" />
        <aid-filter
            android:name="A000000003101001"
            android:description="@string/visa" />
        <aid-filter
            android:name="A0000002771010"
            android:description="@string/interac" />
    </aid-group>

</host-apdu-service>

何かが足りないのですが、何をどこに置くべきかわかりません。

ありがとう。

4

3 に答える 3

9

タップ アンド ペイ メニューに表示するには、HCE アプリでバナー グラフィックを提供する必要があります。android:apduServiceBanner次の属性を使用して、グラフィックを host-apdu-service XML に含めます。

<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:requireDeviceUnlock="true"
    android:apduServiceBanner="@drawable/servicebanner">

    <aid-group android:category="payment"
               android:description="@string/paymentGroup" >
        <aid-filter ... />
    </aid-group>
</host-apdu-service>

サービス バナーは、サイズが 260 x 96 ピクセルのグラフィック ファイル (.png ファイルなど) である必要があります。

于 2014-06-11T11:12:58.013 に答える