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)
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With