7

I am looking for a way to suppress Android Pay app for one activity. iOS has requestAutomaticPassPresentationSuppressionWithResponseHandler method, which allows exactly this - suppressing Apple Pay while the app is in the foreground - I am trying to achieve this on Android.

I have implemented foreground dispatch. This works fine for most NFC tags - tag gets detected in the activity and then is ignored. However, when contactless payment machine is detected, Android Pay app gets triggered instead and I never get onNewIntent call in my activity.

Other than implementing the app to do card emulation and ignoring these requests, which is not really an option for a few reasons, is there anything else I could do to suppress Android Pay? (and other similar payment apps with focus on Android Pay as most popular)

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
sigute
  • 1,143
  • 12
  • 21
  • Have you tried reader-mode (`enableReaderMode()`)? – Michael Roland Dec 07 '17 at 14:28
  • Just tried it, needed to add flags for NFC type, but it works now! :) Thank you. Completely missed that in the documentation, it's not even mentioned other than in the javadoc. – sigute Dec 07 '17 at 16:35
  • Did you find a way how to implement suppressing the payment apps? – Alex Aymkin Nov 19 '21 at 13:14
  • 1
    @AlexAymkin The answer using `enableReaderMode` worked for me at the time, but I haven't worked with this for several years, so not sure if anything changed since. – sigute Nov 19 '21 at 15:46

1 Answers1

3

On Android 4.4 and above, you could use the reader-mode API to explicitly switch the device into reader/writer mode for a specific tag technology. This would disable the other NFC modes (peer-to-peer mode ("Android Beam") and card emulation mode).

nfcAdapter.enableReaderMode(this, new NfcAdapter.ReaderCallback() {
    public void onTagDiscovered(Tag tag) { }
}, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);

Since you also want to ignore discovered tags, you could then simply drop (ignore) the tag handle received through the onTagDiscovered().

Michael Roland
  • 39,663
  • 10
  • 99
  • 206