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.
Asked
Active
Viewed 1,083 times
1 Answers
0
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

Andrew
- 8,198
- 2
- 15
- 35
-
HCE is used for payments right ?? can i use it for data transfer which is in format of simple string ? – Nishita Singh Jan 09 '20 at 12:27
-
HCE is for pretending to be a NFC card, there should be no reason why you cannot pretend to be a NFC card that is carrying a NDEF message that is carrying your String (other than writing the code) as Android Beam was basically doing the same thing with less work. But it is also used to pretend to be NFC enabled bank cards as well. – Andrew Jan 09 '20 at 12:44
-
Is there a working example or something because i am new to android and the link provided by you shows manifest permissions only. – Nishita Singh Jan 13 '20 at 10:04
-
HCE is more advanced stuff and lacking documentation, I've found via google some example code, but I've never tried it. https://github.com/grundid/host-card-emulation-sample and https://github.com/championswimmer/NFC-host-card-emulation-Android – Andrew Jan 13 '20 at 10:52
-
I've found the sources of ndefpush https://android.googlesource.com/platform/packages/apps/Nfc/+/refs/heads/master/src/com/android/nfc/ndefpush/ and it does not look like it uses HCE – Andrew Jan 13 '20 at 11:09
-
Still one question arises..Beam is the default 'mode' of NFC for all Android devices. Only in KitKat (Android 4.4) there is an option to temporarily disable this mode in-app. My main motive is to avoid UI of "Touch to Beam" option. – Nishita Singh Jan 15 '20 at 10:33