Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making NFC/Beam more automatic

I am adding NFC/Beam capabilities to my app and I would like it to work as automatically as possible. I would like to get rid of the "Touch To Beam" screen from the sender and the "New tag scanned" screen from the receiver. Basically, I want it to work like it does in the Samsung commercial!!! I read in stackoverflow that it seems like there may not be a way to get rid of the "Touch To Beam" screen, however I am hoping someone has some updated information or knows how to remove the receiver screen. Thanks!

like image 337
user306517 Avatar asked Oct 06 '22 21:10

user306517


1 Answers

Sending side

When using NFC peer-to-peer communication (aka Android Beam) between two Android (4.0+) devices, there is no way to avoid the Beam UI. So it is not possible to transfer data without the "Touch to Beam".

Before Android Beam (effectively Android 2.3.3-2.3.7), this was possible through foreground NDEF push (which is now (a) deprecated and (b) on Android 4.0+ implemented through Beam). In that case NDEF messages where immediately transfered without the "Touch to Beam" window.

Starting with Android 4.4, there is the possibility to communicate between two Android devices over NFC without the Beam UI (actually without using Android Beam and peer-to-peer mode at all): If both devices are 4.4+, one device can use Android HCE to emulate a contactless smartcard and one device can use the reader-mode API (this only works with the reader-mode API introduced in 4.4, so both devices need to be 4.4+) to communicate with the emulated smartcard.

Receiving side

If you send an NDEF message through Beam, you can at least get the receiving side to do what you want. In that case, you need to register a proper NDEF_DISCOVERED intent filter (that matches the record type/data type of the first NDEF record of the sent NDEF message) in your app's AndroidManifest.xml.

like image 72
Michael Roland Avatar answered Oct 10 '22 13:10

Michael Roland