Android API for inter-device communication - android

I was wondering if there is an API that allows for direct communication between two or more Android devices, particularly for real-time multiplayer gaming. For example, is Bluetooth communication between two devices for the purpose of gaming?
EDIT: I do not have a (reliable) server so I cannot consider it as an option. I am looking for an API that strictly uses direct device communication (so no servers).

http://androidforums.com/android-games/57-mages-multiplayer-android-game-engine-chess-game-included.html
Here is one multiplayer engine i have run across when exploring networking options. I have not used it though so I cannot give any insightful opinion about it.
Generally I tend to lean towards creating my own tcp client / server solution. Of course the best choice for you depends on what type game / application you are looking to make. Generally if you plan to have a good number of users on at a single given time (more than 3+) P2P is strayed away from. That being said i have also yet to see a well working solution for a client / server application over bluetooth, which leaves you with traditional networking strategies.

Yes there are APIs for that now.
"Nearby Connections is a peer-to-peer networking API that allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity."
https://developers.google.com/nearby/connections/overview
Also see:
Wifi P2P
https://developer.android.com/guide/topics/connectivity/wifip2p
Overview on what to select:
https://developer.android.com/training/connect-devices-wirelessly
PS I know this is an old question but it still ranks very high on search engines, therefore I add this answer.

If you're doing Peer-2-Peer, then Bluetooth and/or NFC would be your best bets. I would suggest to using the "Internet" approach through Wifi as it offers more flexibility.

Related

Android to iOS AirDrop?

Out of curiosity... has anyone ever been able to integrate AirDrop functionality into an Android app?
I really don't care about receiving any information on the Android side, but am hoping I can send information to the iOS side from Android. I'm hoping to find someone with a more in-depth understanding of how it works and if it is physically possible. Also, any direction on whether Apple has proprietary use over the protocol (or if it is just the name and branding) would be awesome!
Trying to build a cross-platform app and getting pretty close, but this would just extremely convenient if it works out :)
Currently, it is not possible as AirDrop uses Bluetooth to create a peer-to-peer Wi-Fi network between the devices. Each device creates a firewall around the connection and files are sent encrypted, which actually makes it safer than transferring via email. AirDrop will automatically detect nearby supported devices, and the devices only need to be close enough to establish a good Wi-Fi connection, making it possible to share files across several rooms.
Some Android devices use a combination of Near Field Communications (NFC) and Bluetooth to share files. But both Bluetooth and NFC are relatively slow compared Wi-Fi, which makes sharing larger files using AirDrop much faster and more convenient.
Regarding protocol, I don't think Apple has made it public and as far as I know Apple they must have patented it. Since AirDrop uses Bluetooth as well, and Android and iPhone Bluetooth are not compatible. Hence, due to all these reasons, we did not see any Android app that can send data via AirDrop.

How to make several mobile devices (both iOS and Android) communicate without using internet

I am currently trying to develop a mobile application for both iOS and Android. It basically will be a game buzzer app, determining which of the players is granted a right to answer a specific questions.
The problem is that I struggle to determine which technology / framework I should use for that. Now, some details:
In this app there will be a "base" - it is the phone that gives
"start" signal for all the other players. Each buzzer pressed before this signal corresponds to a false start. Eventually, information
about which player is granted a right to answer or is penalized due
to false start should be displayed on the base device.
App is done for people who have no access to the internet. All the
communication should exists given ONLY mobile phones with no data
plan.
Max number of communicating devices is 9 (1 base and 8 players)
I investigated a lot of resources and this is what I discovered:
Regular WLAN with TCP sockets and etc won't help, since it assumes that all devices are connected to same wireless access point - it violates my requirements.
Regular bluetooth won't help either. This would work across a specific platform, but making Android talk to iOS is impossible.
Situation with Wi-Fi direct is same as with regular bluetooth. Both platforms support this, but Apple's MultipeerConnectivity framework works only with iOS devices.
Now the last option I am left with is BLE. Both platforms support this and are able to intercommunicate (acting both as central or peripheral devices). However, due to my requirements for an app, I assume that base device should act as peripheral, and according to (sometimes conflicting) articles on Internet, one can't connect several central devices to single peripheral.
Now, my questions:
I still assume I might have done some mistakes in the bullet points above, so please, correct me if I am somewhere wrong.
Now when I am left only with BLE option, are there any possible solutions to the above issue? Maybe it is possible to use all devices as centrals (?). I recently saw this example, where everything works cool. Sorry in advance, if I said something stupid.
Of course, there is a counterexample - FireChat, which employs OpenGarden's MeshKit. But the framework is not available. I tried communicating OpenGarden people, but no response. Does anyone know if it is planned to go opensource soon, or maybe there exists any analog of this?
Try the Hype SDK by Hype Labs. It's a multi-transport, multi-hop mesh SDK. It supports interoperable Bluetooth Low Energy (and other transports as well). The SDK is currently in private beta but will be made available upon approval of the subscription.

Wifi direct for Google Glass or other options

I'm trying to create a simple glassware using GDK which wirelessly receives
data from a laptop and uses the data to create some visual representation.
I'm wondering if the current Google Glass supports wifi direct or other kind of
wifi p2p connection, and it can be used for the idea.
Or is Bluetooth the only available option for this kind of applications?
Thank you so much in advance.
Since Glass is basically Android, anything that would work on Android should work with it. I think websockets will do what you want, and there are multiple implementations of that for Android and other platforms.
That said, be sure to remember that Glass is a relatively weak system with a short battery life, so maintaining long lasting communications could be costly. Use caution.

Transfer data between iOS and Android via Bluetooth?

I've been reading up on how to transfer data between iOS devices over Bluetooth using GameKit. I'm not writing a game, per se, but do have a need to transfer a small amount of binary data between two devices. Between two iOS devices, this is easy enough. However, I was wondering if it is possible to transfer data between an iOS device and an Android device via the same mechanism.
Has anyone come across documentation/tutorial that would explain how to do this? Is it even technically possible? Or has Apple put in some sort of restriction that would prevent this?
The other option I discovered was Bonjour over Bluetooth. Would this be a more suitable option for this type of operation?
This question has been asked many times on this site and the definitive answer is: NO, you can't connect an Android phone to an iPhone over Bluetooth, and YES Apple has restrictions that prevent this.
Some possible alternatives:
Bonjour over WiFi, as you mentioned. However, I couldn't find a comprehensive tutorial for it.
Some internet based sync service, like Dropbox, Google Drive, Amazon S3. These usually have libraries for several platforms.
Direct TCP/IP communication over sockets. (How to write a small (socket) server in iOS)
Bluetooth Low Energy will be possible once the issues on the Android side are solved (Communicating between iOS and Android with Bluetooth LE)
Coolest alternative: use the Bump API. It has iOS and Android support and really easy to integrate. For small payloads this can be the most convenient solution.
Details on why you can't connect an arbitrary device to the iPhone. iOS allows only some bluetooth profiles to be used without the Made For iPhone (MFi) certification (HPF, A2DP, MAP...). The Serial Port Profile that you would require to implement the communication is bound to MFi membership. Membership to this program provides you to the MFi authentication module that has to be added to your hardware and takes care of authenticating the device towards the iPhone. Android phones don't have this module, so even though the physical connection may be possible to build up, the authentication step will fail. iPhone to iPhone communication is possible as both ends are able to authenticate themselves.
Maybe a bit delayed, but technologies have evolved since so there is certainly new info around which draws fresh light on the matter...
As iOS has yet to open up an API for WiFi Direct and Multipeer Connectivity is iOS only, I believe the best way to approach this is to use BLE, which is supported by both platforms (some better than others).
On iOS a device can act both as a BLE Central and BLE Peripheral at the same time, on Android the situation is more complex as not all devices support the BLE Peripheral state. Also the Android BLE stack is very unstable (to date).
If your use case is feature driven, I would suggest to look at Frameworks and Libraries that can achieve cross platform communication for you, without you needing to build it up from scratch.
For example: http://p2pkit.io or google nearby
Disclaimer: I work for Uepaa, developing p2pkit.io for Android and iOS.
You could use p2pkit, or the free solution it was based on: https://github.com/GitGarage. Doesn't work very well, and its a fixer-upper for sure, but its, well, free. Works for small amounts of data transfer right now.

WiFi Direct the right choice? Trying to make chat app - Android

I'm trying to make a simple chat app on Android for learning purposes. I would like it to have the following features: Different "rooms" which people can create/join. Working of Bluetooth/WiFi Direct (Preferably WiFi direct). Passwords on rooms.
I'm having a number of problems however. I don't fully understand WiFi Direct. I've read and re-read the guides and references on developer.android.com and I've asked multiple times on #android-dev on freenode to no avail. Would someone be able to explain if what I outlined is even possible using WiFi direct and if not, what should I use?
TL;DR: Explain WiFi Direct's network structure and capabilities and provide resources for learning if possible.
It is possible using WiFi direct.A room can be considerd a P2P group(1 group owner+ one or more clients) .The person who starts a "room" becomes a P2P group owner and whoever wants to join a group has to undergo the authenticatio process.A client can directly communicate with owner but to communicate with other clients in the group it has to go through the owner.
For detailed understanding of wifi direct better go through the wifi p2p tecnical specification v1.2 which can be found in WiFi alliance website under published specs. Or for a overview Click [here] (http://enjambre.it.uc3m.es/~agsaaved/papers/2012_camps_wircommag.pdf).
It is possible in theory but currently the framework of wifi-direct is too unreliable..
I have tried it and the connection is very unreliable ,it breaks abruptly for no reason. Also beyond 3 devices it doesn't scale very well ,though i tested it on tablets having very less processing power (maybe on good phones it might allow one or two more connections).
So i would recommend you use wifi for communication . it would be the best suited for your needs and easier to work with as well

Categories

Resources