Although Apple still dominates the Wearables market, from the look of things, Google is catching up. Android Wear is becoming more and more popular every day and at the moment, according to Mashable, there are over 4000 Android Wear apps on the market today.
The True Potential of Android Wear
Of course, Android Wear offers a ton of great features out of the box, like push notifications, calendar, etc. However, the true potential lies in the ability to create new and exciting applications, which communicate with your wearable device, when paired with a smartphone.
And in order to help developers, Android has come out with a number of APIs, such as the Node API, Message API, and DataLayer API, which make the job a lot easier. Every one of these APIs has its unique purpose. DataLayer API, for instance, allows the phone and the app to synchronize seamlessly.
How to Handle Errors With Connect()
If you’re using the Wear APIs in your development efforts, you definitely need to know how to handle all of the error conditions if you want everything to go smoothly down the line. The errors mainly occur when users download your app without having a wearable device.
In order to avoid this, you need to make sure that all of the error conditions are handled properly. Luckily, you can handle everything with the “connect()” method, and ensure that the app won’t fail even when people who don’t own a wearable device install it.
The error called “ConnectionResult.API_UNAVAILABLE” shows up in two specific cases:
- When the API makes a request on a device that runs on Android 4.2 or an earlier version
- When the API isn’t able to find an Android Wear companion device for the phone
Now, there are numerous features that Google Play offers, such as the integration with Google Wallet, Drive, and Games, just to name a few. When the initialization happens, your app utilizes “GoogleApiClient.Builder()” to calls the “addApi()” to request all of the necessary features.
The app then calls the “connect()” method to establish a connection with the Google Play library. However, if any APIs are missing, the method can also send error messages to the user.
Since the Android Wear service is not available on all smartphones and tablets, you need to make a separate client for this particular request. The best way to do this is to create two distinct GoogleApiClient connections:
- You need to create a single connection that supports the Android Wear API
- You also need a connection that supports all of the other APIs your app needs
And that’s basically all you need to do. You just need to do a little bit of coding and voila – your users won’t encounter any errors while they are connecting your app to their Android Wear device.
The Bottom Line
Last but not least, you should also check the API documentation service once again, just to make sure that you’ve followed the instructions correctly. In certain situations, people lose focus and make mistakes. Therefore, it would be wise to check and see whether or not you’re responsible for the error.
Nonetheless, by following the steps we laid out above, you’ll make sure that your app is functional at all times for all users, no matter if the wearable service is available on their Android device or not.
The biggest thing to remember here that you need to implement the aforementioned practices as soon as possible. Otherwise, you may start losing users sooner than you think. Make sure your app is error-free before your users become affected.