1

I'm facing a strange issue in my HCE payments. I have two payments application in my mobile. One was developed by me and other is Android pay. In Tap&Pay the default one is "Android Pay" and my app is non-default and enabled "Favour foreground app".

Now my problem is when I try to make payments (Tap device to POS), the device always prompting "Android Pay" instead of my app.

I followed all guidelines given in Android documentation.

Android HCE guide

Do I need to enable anything in my code to make this happen?

Santhi Bharath
  • 2,818
  • 3
  • 28
  • 42

1 Answers1

4

In order to leverage the "Favor Foreground App" preference, you need to tell CardEmulation that your app is ready to intercept the terminal tap. By default, your app won't intercept the tap.

In our app, I do this in onPause() and onResume() in each Activity (or you can extend a common Activity and just do this once.

in onResume() call public boolean setPreferredService (Activity activity, ComponentName service)

in onPause(), call public boolean unsetPreferredService (Activity activity)

Sam Edwards
  • 874
  • 8
  • 19