Sending large files with Android Beam (or S-Beam)

2019-03-01 05:59发布

问题:

I've been tasked with adding support to an app for beaming large data files (tens of megabytes) from device to device via 'NFC' on Android.

I'm aware that genuine NFC on Android is painfully slow, but I know that ICS has support for doing hand-off of the bulk data transfer to Bluetooth; and Samsung have a proprietary mechanism for doing the same via Wifi Direct (S-Beam). So that's the approach I'd want to take.

Unfortunately I cannot find any information on how to actually do this.

I've looked at the Android Beam documentation, and there's no mention of special mechanisms to support large bulk data; so I took the standard AndroidBeamDemo app and simply added a large byte array to the packet size, in the hope that it would all Just Work. It seems not to --- sending a 10kB message takes about five seconds, and trying to send a 1MB message just doesn't do anything at all (although it tells me the message was sent successfully).

For Samsung's S-Beam, I simply cannot find any documentation whatsoever.

Has anybody made this work, and if so, can they point me at an example?

回答1:

For Android Beam, you need to provide URIs to the files with the data using setBeamPushUris() (or setBeamPushUrisCallback() if the data is not fixed).

For S-Beam, I am not aware of any API that can be used. AFAICT, S-Beam only works with the built-in apps for pictures, video and music.