

Google Play services every`wear`…
Recently, I bought a Moto 360 2 generation (BTW, I am loving it…) and as mobile developer I started to thinking in adding the Wear features to one of my applications that I developed on my leisure time.
My first thought was “this should be easy” - It was also my first mistake.
I have a lot of experience with Android development, so I started by opening the Android Studio and wrote the code. I opened a project with one of my applications and added the Android wear module. The walkthrough to the creation of the Android Wear module works fine and at the end of the process I had an Android Wear application with the “Hello Round World!”.
“Great, Android Wear development looks like the normal Android development…” - This was my second thought and mistake.
OK, great, I have an Android wear module, lets see how to send it to my moto 360!
To send it to the my brand new moto 360, I just followed the documentation and it was easy, but it is not a great experience, I have to admit:
- Connect the Android device;
- Enable the ADB debugging on android wear;
- Enable the Debug over bluetooth on android wear;
- Enable the debug on the Android wear application on the mobile device;
- Go to the ADB console and run 2 commands;
- Hit the run button and there it is “Hello World” on the screen.
The application I am trying to integrate with Android Wear is an application that shows the results of the EuroMillions.
“Ok, lets instantiate a Raffle object…”
Now that I had the Mobile and Wear module “Ok, lets instantiate a Raffle object”, not so fast… The code is not shared between modules, so lets do a surprise refactoring and move all the model and logic layer to a new module shared by both modules (Wear and Mobile). Problem solved.
Look son, google play services every`wear´!
With everything connected lets make a network request to get the results… So, I copied the Parse code used to make the request on the Mobile module, pasted on the Wear module, pressed Run….no compile errors and BOOOM, nothing. What is not working? After searching on the web… I discovered that the Android Wear cannot make direct HTTP request. I read about that, and it makes sense…It is a device with a very limited amount of resources, so should be the mobile application to do that. Every Wear application needs a Mobile application, I can live with that, and it makes sense…
So, lets see how to send data to the Wear module. Reading the documentation the only solutions available are:
- Messages, as a fast method to send something to the Wear device;
- Data Items, as a reliable method to send something to the Wear device.
Both of the methods are attached to the Google Play services libraries. That are attached to the Google Play Services. That are attached to Android devices with Google Play Services.
On the Android development for mobile devices, Google Play services helps a lot, and I love them. Besides that, if I don’t want to include them, I can do that, and I can do almost anything without them.
In my opinion, with the release of the Android 5.0 or even the 6.0, Google should have to included the native methods to communicate with the Wear without the Google Play services dependency. I understand the Google’s view, and I know that it is more easy to iterate, support, improve over the Android Wear with the Google Play services dependency. Besides that, again, in my opinion, there should exists another way. The developers should have the freedom to not use the Google Play services (the developers could use the low level bluetooth api’s, but the effort is to high… For me it is not an option). I am not 100% sure, but I think that without the Android Wear app (that is only available in the Google Play Store) it is not possible to activate the Wear device in the first boot.
Conclusion, if an Wear application needs a Mobile application. To communication between them I need Google Play services. To have a Google Play services I need a device approved by Google. Why not just call it Google Wear or Play Wear. And instead of Android Wear development, Google wear development, or Play Wear development. Just my 2 cents…
About the Wear update, I didn't released it yet. I decided to take the Udacity class about Android Wear development…