Enable interactions between nearby devices and people
With the Nearby APIs you can let your users work or play together better when they're close, within about 100 feet: easily set up multiplayer games, ad hoc groups, sharing, or collaborative sessions.
Why it works
The unique ranging and cross-platform capabilities of Nearby make it easy to build experiences that seem magical when users are close by. This increases engagement among users who use your Nearby powered features and encourages users to share your app.
- Messaging API: Broadcast and receive messages to enable rich interactions and collaboration among users such as multiplayer gaming, real-time collaboration, forming a group, broadcasting a resource, or sharing content.
- Nearby Connections API: Discover other devices on the same local network and create connections for real-time cross-device experiences. With one device acting as the host, nearby devices can request to connect for collaborative whiteboards, local multiplayer gaming, or multi-screen gaming.
- Nearby Notifications: Receive messages from beacons using Eddystone and add context to location-based apps and games. Messages can be a link to an HTTPS URL that provides a notification to the user and opens the URL in the browser when the user taps the notification. Alternatively, messages can trigger an app intent to launch an app and perform a specific action or take the user to the Play Store if the app isn't installed.
- Use Nearby features sparingly and only when they're needed, to preserve battery life. This is because the Nearby APIs make extensive use of radio and sensor features, consuming battery up to 3.5 times faster than normal.
- Use an explicit action to invoke Nearby, such as a button, switch, or special screen. Provide the user with a visual indicator — for example, an animation — to show Nearby is actively sending or receiving content. Use the Nearby logo found at developers.google.com/nearby.
- Make sure the user understands what data will be visible to nearby users of your app before they start using Nearby features.
Stop any publish or subscribe activity when the app doesn't need nearby or is exited. Do this by calling
unsubscribe()in your Activity's
Limit the range of Nearby features by, using the ultrasonic modem alone by specifying
Strategy.setDistanceType(DISTANCE_TYPE_EARSHOT). This restricts the range to about five feet and ensures only devices in the same room can "see" the initiator.
Speed up the exchange of data where one side is publishing only and the other side is subscribing only, using
Strategy.setDiscoveryMode(DISCOVERY_MODE_BROADCAST)on the publishing side and
DISCOVERY_MODE_SCANon the subscribing side. Publish and subscribe are orthogonal to discovery mode (the publisher could scan and subscriber broadcast or vice versa).