I implemented HCE (Host card emulation) for my application. When am trying to communicate with payment terminal it is working in Sony (6.0) but it is opening a default app even though i set (Except when another payment app is open) in tap and pay section in Nexus 6P (OS : 8.1). Can anyone please help me with this. Why is it working fine in one phone and not in another? I can't even see my application in tap and pay section in Nexus 6P (OS : 8.1). Do I have to add any additional code in OS: 8.1 ?
My code: (I used this code from the different post in StackOverflow but it doesn't have ans for my problem)
Following code is returning false for the app.
boolean isDefault = CardEmulation
.getInstance(NfcAdapter.getDefaultAdapter(this))
.isDefaultServiceForCategory(
new ComponentName(this, MyPaymentService.class),
CardEmulation.CATEGORY_PAYMENT);
Service declaration in manifest:
<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="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>