Android Gets A Peer-to-peer Network API
Written by Harry Fairhead   
Wednesday, 02 August 2017

This could be big news if sufficient programmers take it seriously and think up creative uses and killer apps. Nearby Connections 2.0 provides fully off-line networking via WiFi, Bluetooth BLE and classic and the only question is what to do with this exciting feature?


The Weather Channel seems to have the right idea. It is planning an on-demand network to make up for communications deficit to spread weather warnings. Hotstar is planning to let people share media when there isn't Internet connectivity. GameInsight and Google on the other hand seem to be planning some fairly unimaginative uses - to find nearby players and a remote for Android TV.

Google seems to think that this feature is more about localization and interacting with devices rather than anything more interesting - we can already do both via WiFi.

When you realize that what you have is a socket-like API that will shield you from the complexities of a phone's different radio subsystems. You can build a star or cluster network for 1 to N or M to N communication and using what ever radio protocols happen to be available:

Nearby Connections uses WiFi, Bluetooth LE & Classic Bluetooth under the hood to discover and establish connections to nearby devices. It abstracts away the inherent complexity of these radios by leveraging the strengths of each, while circumventing their respective weaknesses. Aside from the obvious advantage of sidestepping the pain of dealing with the vagaries of these radios across different OS versions and devices, this abstraction enables seamlessly upgrading the bandwidth of a connection by switching between the radios as and when it makes sense, as well as getting invisible over-the-air updates to use new radio technology as it becomes available -- with no change whatsoever in the application code.


There is an API call for discovering nearby devices and advertising your devices availability. The previous version of the API required a common multicast enabled WiFi connection to make discovery and connection work and if you think about it this makes the whole idea of a near connection network fairly redundant.The new system makes it possible to have network connections between devices even when there is no Internet. Although this is "Nearby" connections devices can be up to 100m apart.

Once a connection is made you can transfer bytes, files or streams of data. Byte payloads can be up to 32Kbytes in a single transaction but file and streaming transactions are unlimited. You can use encryption so that only the destination end point can read the data.

You can use the API with any device that has Google Play Services 11. It is worth noting that again a possibly important part of the Android operating system is supported by Play and hence 100% under Google's control. There is no charge to use the new service but there could be in the future although given it works offline no Google servers are involved.




Notice that this isn't true mesh networking as the communications are point-to-point and there is no routing. With the addition of routing the network could be much larger than 100m as connections could be passed through intermediate nodes. The possibilities for a nearby mesh network are much greater. Can this be added at the application level?


More Information

Announcing Nearby Connections 2.0: fully offline, high bandwidth peer to peer device communication

Nearby Connections API

Related Articles

Android Studio 3

Android Gets Architecture Components

Kotlin - New Language For Android

Android Instant Apps Enter Live Testing

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.




Digital Play Shown To Be Good For Kids

When designed with their needs in mind, video games can benefit children’s well-being. This finding comes research from  UNICEF in partnership with LEGO and the University of Sheffield.

JetBrains Releases Aqua Test Automation IDE

JetBrains has announced the public release of Aqua, its IDE designed for test automation. The full release follows a preview in 2022.

More News


raspberry pi books



or email your comment to:



Last Updated ( Wednesday, 02 August 2017 )