1

With Android 4.1+, what would be the most simplistic way to pass a unique string to the sender->receiver, and then back receiver->sender?

Ex. 2-way communication using NFC with only one user pressing the "Touch to Beam" UI

Edit: I would like this to be accomplished without the need of a cellular connection so that Wifi tablets could perform this action as well

WeldFire
  • 194
  • 1
  • 3
  • 8
  • That is an interesting idea! Using NFC to initiate a sms that is bounced between two devices would technically work, however I would like this to be compatible with devices that don't have a cellular connection. I guess I should update my original post... – WeldFire Apr 03 '15 at 16:11
  • You could send push notifications to each other using Google Cloud Messaging, idk if that's what you're looking for. – Eric S. Apr 03 '15 at 16:24

2 Answers2

0

You can use wifi p2p (aka wifi direct) to set up a P2P local wifi network to do file transfer. You can read the official guide/draft here (code sample included, Android 4.0 or later required).

Or you can use NFC (see this helper class, which helped me a lot).

Community
  • 1
  • 1
Darkseal
  • 9,205
  • 8
  • 78
  • 111
  • NFC would be preferable, I would like to get around the users having to tap phones twice. What I have found, this wouldn't be possible above Android 2.3? or am I incorrect? – WeldFire Apr 03 '15 at 16:08
0

@Comment WeldFire: Not entirely correct. Android beam always needs a user action to transmit data (via NFC), see this question.

If you need transmission via NFC, you need to use NFC host card emulation respectively tag reader, which is more complicated but allows transmission without user interaction (requires API19 = Android 4.4+), see docu.

It is also possible to have automatic wifi p2p connection, see this blog with example code. In my oppinion this is the easiest and best performing way to build a connection between to Android devices without user interaction.

Community
  • 1
  • 1
hengsti
  • 310
  • 3
  • 11