Can Android Pay be disabled in-app?
Asked Answered
E

1

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)

Essex answered 7/12, 2017 at 14:4 Comment(4)
Have you tried reader-mode (enableReaderMode())?Lewanna
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.Essex
Did you find a way how to implement suppressing the payment apps?Tenorio
@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.Essex
L
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().

Lewanna answered 7/12, 2017 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.