Tag Archives: wifi

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

Posted by Ritesh Nayak M, Product Manager

Imagine walking into a hotel room and having the temperature set just right, your favorite sub-genre of progressive-math-rock playing in the background, and the TV urging you to continue binging on your saved guilty-pleasures watchlist. What if your phone's contact book could expand to merge with your spouse's when you're together, so you're never again put in the excruciatingly compromising position of having to ask for your mother-in-law's phone number (which you ought to have had on speed dial, in your favorites, and listed as an emergency contact)? Now imagine a world where you can drive up to an empty driveway or private parking space in a city like New York or San Francisco, and negotiate with that space to rent it out until its owner returns.

The common thread among all these scenarios is being able to detect proximity to -- and being able to communicate with -- people, places, and things "near" you.

At I/O this year, we spoke about a refresh to the Nearby Connections API that can provide high bandwidth, low latency, encrypted data transfers between nearby devices in a fully-offline P2P manner. Today we're announcing the availability of this API across all Android devices running Google Play services 11.0 and up.

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.

At the heart of this API is a connection (with Unix-socket-like semantics) that you can use to transfer bytes, files, or streams of data. There are two supported connection topologies:
  • Star: Useful for creating 1:N topologies where there's a centralized device that others are especially interested in. For example, the host of an offline game, or the teacher's device in a classroom quiz app.
  • Cluster: Useful for creating M:N topologies that allow for creating looser mesh-like networks. For example, a classroom app that supports forming ad-hoc project groups for realtime collaboration, or an offline hyper-proximity-based chat app.
As a part of the process of building this API we worked with a few partners, each with unique offline-data-transfer needs and environments. It's been great to see what they've built on top of early versions of this API, and their feedback has been invaluable in guiding us towards today's launch. Take a look at some of the cool things they're building:
  • The Weather Channel is building on-demand mesh networks in data-deficient areas to spread urgent weather warnings.
  • Hotstar enables offline media sharing in places with spotty/no internet connectivity (like on public transportation, airplanes, etc.)
  • GameInsight is using Nearby Connections to not only find nearby players, but also to run entire games offline.
  • Android TV is building a remote control app (powered by Nearby Connections) to simplify initial setup, and to enable subsequent second screen experiences.
Now that the API is publicly available, we can't wait to see how you will use Nearby Connections in your applications. To get started, visit our developer site, check our code samples, and post any questions you have on Stackoverflow (tagged with google-nearby). To stay up to date on the latest Android Nearby offerings (and our other Context-related APIs), please subscribe to our mailing list.



Interactive watch faces with the latest Android Wear update

Posted by Wayne Piekarski, Developer Advocate

The Android Wear team is rolling out a new update that includes support for interactive watch faces. Now, you can detect taps on the watch face to provide information quickly, without having to open an app. This gives you new opportunities to make your watch face more engaging and interesting. For example, in this animation for the Pujie Black watch face, you can see that just touching the calendar indicator quickly changes the watch face to show the agenda for the day, making the watch face more helpful and engaging.

Interactive watch face API

The first step in building an interactive watch face is to update your build.gradle to use version 1.3.0 of the Wearable Support library. Then, you enable interactive watch faces in your watch face style using setAcceptsTapEvents(true):

setWatchFaceStyle(new WatchFaceStyle.Builder(mService)
    .setAcceptsTapEvents(true)
    // other style customizations
    .build());

To receive taps, you can override the following method:

@Override
public void onTapCommand(int tapType, int x, int y, long eventTime) { }

You will receive events TAP_TYPE_TOUCH when the user initially taps on the screen, TAP_TYPE_TAP when the user releases their finger, and TAP_TYPE_TOUCH_CANCEL if the user moves their finger while touching the screen. The events will contain (x,y) coordinates of where the touch event occurred. You should note that other interactions such as swipes and long presses are reserved for use by the Android Wear system user interface.

And that’s it! Adding interaction to your existing watch faces is really easy with just a few extra lines of code. We have updated the WatchFace sample to show a complete implementation, and design and development documentation describing the API in detail.

Wi-Fi added to LG G Watch R

This release also brings Wi-Fi support to the LG G Watch R. Wi-Fi support is already available in many Android Wear watches and allows the watch to communicate with the companion phone without requiring a direct Bluetooth connection. So, you can leave your phone at home, and as long as you have Wi-Fi, you can use your watch to receive notifications, send messages, make notes, or ask Google a question. As a developer, you should ensure that you use the Data API to abstract away your communications, so that your application will work on any kind of Android Wear watch, even those without Wi-Fi.

Updates to existing watches

This update to Android Wear will roll out via an over-the-air (OTA) update to all Android Wear watches over the coming weeks. The wearable support library version 1.3 provides the implementation for touch interactions, and is designed to continue working on devices which have not been updated. However, the touch support will only work on updated devices, so you should wait to update your apps on Google Play until the OTA rollout is complete, which we’ll announce on the Android Wear Developers Google+ community. If you want to release immediately but check if touch interactions are available, you can use this code snippet:

PackageInfo packageInfo = PackageManager.getPackageInfo("com.google.android.wearable.app", 0);
if (packageInfo.versionCode > 720000000) {
  // Supports taps - cache this result to avoid calling PackageManager again
} else {
  // Device does not support taps yet
}

Android Wear developers have created thousands of amazing apps for the platform and we can’t wait to see the interactive watch faces you build. If you’re looking for a little inspiration, or just a cool new watch face, check out the Interactive Watch Faces collection on Google Play.