-1

So i have been looking into close range data exchange. Trying to exchange some strings and variables between close ranged devices.

I have been looking into Google Nearby Connections But that doesnt really seem optimal since i need both devies to Look for devies and Advertise itself to other devies.

And for it to be limited to a closer distance between phones like when two phones touch.

How would you people do something like this?

1 Answers1

1

Unfortunately Android Beam has been Deprecated in Android 10 replaced by google nearby, because it was unreliable as Bluetooth and Wifi Direct are better.

If you real want to use NFC (which not every phone has) then one Android device could use Host Card Emulation (HCE) and emulate a real NFC card https://developer.android.com/guide/topics/connectivity/nfc/hce.

You would get it to emulate a card with an NDEF message with a custom mime type data on it and if you App was installed on the receiving Android Device with the correct Intent Filter https://developer.android.com/guide/topics/connectivity/nfc/nfc#filter-intents for the custom mime type, you App would be launched and passed the custom data or if your App was already running and it enableForegroundDispatch https://developer.android.com/guide/topics/connectivity/nfc/advanced-nfc#foreground-dispatch it would just pass it the data.

If you App was not installed on the receiving Android Device you could also put and AAR record on the emulated card https://developer.android.com/guide/topics/connectivity/nfc/nfc#aar which would send the user to the App store to get your App.

Programming HCE is not the easiest to do and you would need to emulate the NDEF AID (you are basically emulating a type 4 tag which spec is at http://apps4android.org/nfc-specifications/NFCForum-TS-Type-4-Tag_2.0.pdf)

Probably easiest to get a real NFC tag, and play around with NDEF messages on it to make sure you can get it to do what you want (the real card would be simulating the phone doing HCE) before you dive in to programming the HCE part. This is because there are many Apps to write the NDEF message you need to send between devices to a real card.

Andrew
  • 8,198
  • 2
  • 15
  • 35
  • Would be nice too see some examples having a hard time understanding this – danilkp1234 Aug 17 '20 at 15:18
  • Unfortunately this is complicated and rare thing to do, I've not come across any code examples to share with you on exactly how to do it as you are working around Android Beam being removed which only happened recently. – Andrew Aug 17 '20 at 16:20
  • I dont really get why android beam was removed. Also couldnt this be done with ble like the covid contact tracing app – danilkp1234 Aug 19 '20 at 08:43
  • It is common practise by Google to do things to see if they take off and make money for them and if they don't then they get dropped because it costs money to run/support them. With Android Beam they actually said they would actually hand over support to any device manufacturer who wanted to continue support in their own devices. But Google themselves would not provide it in the base Android or their devices. Also I did mention in the answer this would be better with Bluetooth/BLE or Wifi which could be used directly or via Google Nearby Connections – Andrew Aug 19 '20 at 09:55
  • i have being looking into using Google Nearby Connections. But what is holding me back is that i need to have both devices exchange data and both advertise and discover while also being limited to earshot distance which is not possible in the Connections api. Can it be done with bluetooth without any hassle for the end user like them not needing to go into settings to find the other device and select it – danilkp1234 Aug 21 '20 at 13:30
  • Does anybody know if you can use Google Nearby Connections and limit it to earshot distance or is it open source so I can suggest a feature like that? – danilkp1234 Sep 27 '20 at 14:01