Search code examples
nfcandroid-beam

Data transfer between devices using NFC avoiding Android Beam UI


In the app data transfer (String format) takes place via NFC. In this case a device acts as sender and another one as receiver. Whenever I tap the device to another one, "Touch to beam" option comes. Can I avoid that screen? Is it possible to send data via NFC by avoiding "Touch to beam" option.


Solution

  • Yes you can send data via NFC directly from your App with Android Beam https://developer.android.com/reference/android/nfc/NfcAdapter.html#setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback,%20android.app.Activity,%20android.app.Activity...)

    BUT this is unsustainable as this method has been deprecated (As has the whole of Android Beam)

    You could do Host Card Emulation instead on the sender https://developer.android.com/guide/topics/connectivity/nfc/hce but that is very complicated

    Better to use Bluetooth or Wifi Direct/P2P