Develop and debug Android Wear apps
- Transfer
Wearable devices are the cutting edge of today's information technology. This is a powerful trend. The most popular “wearable computers” are powered by Google’s Android Wear OS. It is not so different from that Android, which is familiar to a huge number of developers. As a result, any of these developers can start creating Android Wear applications without any special difficulties and claim their share of attention from a very promising market for “wearable applications”.
In this article, we’ll talk about the Android Wear OS , paying special attention to the devices running it, the types of applications, their development and debugging. In particular, consider two ways to debug using ADB.
The concept of “portable computer” is suitable for a wide range of “computers”. Among them are headsets for telephones, medical and sports devices, “digital jewelry” and even computers for animals. However, today the so-called “smart watches” are most widely used.
The largest manufacturers of equipment produce their own series of watches, which are carried on board Android Wear. Among the devices of this type can be noted ASUS ZenWatch 2, Motorola 360, LG Watch Urbane, Samsung Gear S, Sony SmartWatch 3. These watches look differently, but their functionality, thanks to the same software platform, has a lot in common. This is the Google Now application, the ability to track the user's physical activity, music playback controls, support for voice commands.
All smart watches have one more thing in common: they depend on smartphones, interacting with them using Bluetooth. This approach is used not only in the Android environment, but also on the iOS platform. The interaction of smartphones and tablets with the clock at the software level is provided thanks to special related applications.
Although Android Wear is a relatively new project, the Android Wear Center , a platform similar to Google Play, offers many applications designed specifically for wearable devices.
Smart Watch Application Store
There are programs for every taste. Every day, Android Wear Center publishes new applications for personalizing watches, for working with music, applications for organizing work with communication functions, development for health, sports and others. Despite the small size of the clock screens, there are games for them. For example - arcades and puzzles, although there are not so many "portable games" yet.
Games for smart watches
The vast majority of applications are dials that allow you to configure the main “clock” function - time display.
Watch applications
On the one hand, writing applications for smart watches is very similar to creating programs for tablets and smartphones. Tools that are familiar to Android developers, such as the JDK, Android SDK (the Android Wear platform supports most of the Android API), Eclipse, Android Studio, or other integrated development environments, are being dealt with. Here you can find a list of classes from the Wearable Support Library.
On the other hand, Google has published a creative concept and design principles.created specifically for those who develop “wearable” applications. These documents reveal the main differences between mobile and wearable technologies. When developing applications, you need to take into account the small screen size of smart watches and the special nature of user interaction with the device. In addition to this, you need to take into account the structure of the application , the dependence of the behavior of the programs on the context , the features of the user interface , the style and the ability to create dials .
Debugging is something the process of creating any program code is not without. Android Wear is no exception. In this section, we will consider debugging “wearable” applications using the example of the LG G Watch R connected to the Nexus 4.
Android Wear supports two debugging methods: using a wired USB interface and wireless Bluetooth .
Regardless of which method of connecting smart watches with a PC is selected, you need to perform the following preparatory steps.
After that, if you plan to use USB debugging, the following actions are performed.
After performing the above steps, the state of the devices will change, this can be seen in the figure.
Changing Device Connection Information
When the connection is successful, the list of devices recognized by ADB will look something like the following.
List of devices recognized by ADB
Now that all the preparatory steps have been completed, the applications on the clock can be debugged using ADB commands.
ADB can not only debug applications. The capabilities of this tool are much wider. For example, taking a screenshot on a watch is not such a simple task as it might seem at first glance. So, the team for taking a screenshot in a program that provides communication with the clock makes copies of the screen, but can only send them via e-mail or publish on social networks. In order to get a copy of the clock screen on a computer, it is most convenient and fast to use the corresponding ADB commands:
Please note that the watch’s screen is round and the screenshot is square. This should be considered when developing applications and working on their usability. If the application interface element is visible on a screen copy, it does not necessarily appear entirely on the watch screen.
Square screenshots of watches with a round dial
The union of modern technologies, such as the Intel Quark processor and the Android Wear operating system, opens up new opportunities not only for device developers, but also for application creators.
As you can see, an Android developer with experience in creating applications for smartphones and tablets can easily switch to programs for wearable computing devices such as smart watches. It is only necessary to take into account some features and you can get down to business.
Devices
The concept of “portable computer” is suitable for a wide range of “computers”. Among them are headsets for telephones, medical and sports devices, “digital jewelry” and even computers for animals. However, today the so-called “smart watches” are most widely used.
The largest manufacturers of equipment produce their own series of watches, which are carried on board Android Wear. Among the devices of this type can be noted ASUS ZenWatch 2, Motorola 360, LG Watch Urbane, Samsung Gear S, Sony SmartWatch 3. These watches look differently, but their functionality, thanks to the same software platform, has a lot in common. This is the Google Now application, the ability to track the user's physical activity, music playback controls, support for voice commands.
All smart watches have one more thing in common: they depend on smartphones, interacting with them using Bluetooth. This approach is used not only in the Android environment, but also on the iOS platform. The interaction of smartphones and tablets with the clock at the software level is provided thanks to special related applications.
What to design for smart watches?
Although Android Wear is a relatively new project, the Android Wear Center , a platform similar to Google Play, offers many applications designed specifically for wearable devices.
Smart Watch Application Store
There are programs for every taste. Every day, Android Wear Center publishes new applications for personalizing watches, for working with music, applications for organizing work with communication functions, development for health, sports and others. Despite the small size of the clock screens, there are games for them. For example - arcades and puzzles, although there are not so many "portable games" yet.
Games for smart watches
The vast majority of applications are dials that allow you to configure the main “clock” function - time display.
Watch applications
How to develop?
On the one hand, writing applications for smart watches is very similar to creating programs for tablets and smartphones. Tools that are familiar to Android developers, such as the JDK, Android SDK (the Android Wear platform supports most of the Android API), Eclipse, Android Studio, or other integrated development environments, are being dealt with. Here you can find a list of classes from the Wearable Support Library.
On the other hand, Google has published a creative concept and design principles.created specifically for those who develop “wearable” applications. These documents reveal the main differences between mobile and wearable technologies. When developing applications, you need to take into account the small screen size of smart watches and the special nature of user interaction with the device. In addition to this, you need to take into account the structure of the application , the dependence of the behavior of the programs on the context , the features of the user interface , the style and the ability to create dials .
How to debug?
Debugging is something the process of creating any program code is not without. Android Wear is no exception. In this section, we will consider debugging “wearable” applications using the example of the LG G Watch R connected to the Nexus 4.
Android Wear supports two debugging methods: using a wired USB interface and wireless Bluetooth .
Regardless of which method of connecting smart watches with a PC is selected, you need to perform the following preparatory steps.
- Install ADB on the developer's computer.
Android Debug Bridge (ADB) is a command-line tool that allows the computer to interact with devices running Android OS or with corresponding emulators. - Preparing the device.
In order to debug applications for Android Wear, you need to enable debugging on devices. This must be done both on the smartwatch and on the smartphone to which they are connected. If the device is being used for debugging for the first time, you need to open its Settings, go to the About section and touch the Build number element seven times. After that, a new line will appear in the list of device settings - Developer Options. On devices of different manufacturers, item names may look different.
Enabling developer mode on a smart watch - Go to the developer settings section and enable debugging using ADB.
Enabling ADB debugging on smart watches
After that, if you plan to use USB debugging, the following actions are performed.
- Connect a wearable device to a PC using a USB cable.
Connecting the watch to a PC using a USB cable - Enable debugging applications on the clock.
To do this, click OK in the pop-up window with the appropriate question. It will appear on the smartphone or tablet with which the watch is associated.
For USB debugging of applications on the clock, you need to enable it on your smartphone or tablet.
In order to check whether the ADB recognizes smart watches connected to the computer, you can use the adb devices command on the command line.
The result of the adb devices command
After that, everything is ready to debug wearable applications via USB. But if you decide to use Bluetooth debugging, then preparing for it will be a little more difficult. To do this, follow these steps. - Enabling the ability to debug via Bluetooth (Debug over Bluetooth) on the watch.
Turn on Bluetooth debugging on your watch - Enable debugging via Bluetooth (Debug over Bluetooth) in the application, thanks to which the smartphone or tablet interacts with the clock. The figure highlights the area in which the status of the devices is displayed.
Turn on Bluetooth debugging on your smartphone and connection information - Connect a smartphone or tablet connected to the clock to a computer via USB and enable debugging via USB.
USB debugging permission on the phone - Running the following ADB commands on the command line:
adb forward tcp:4444 localabstract:/adb-hub adb connect localhost:4444
- Enabling on a smartphone or tablet the ability to debug a wearable device connected to it.
Enable debugging a wearable device connected to a smartphone
After performing the above steps, the state of the devices will change, this can be seen in the figure.
Changing Device Connection Information
When the connection is successful, the list of devices recognized by ADB will look something like the following.
List of devices recognized by ADB
Now that all the preparatory steps have been completed, the applications on the clock can be debugged using ADB commands.
How to take screenshots on the watch?
ADB can not only debug applications. The capabilities of this tool are much wider. For example, taking a screenshot on a watch is not such a simple task as it might seem at first glance. So, the team for taking a screenshot in a program that provides communication with the clock makes copies of the screen, but can only send them via e-mail or publish on social networks. In order to get a copy of the clock screen on a computer, it is most convenient and fast to use the corresponding ADB commands:
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png
Please note that the watch’s screen is round and the screenshot is square. This should be considered when developing applications and working on their usability. If the application interface element is visible on a screen copy, it does not necessarily appear entirely on the watch screen.
Square screenshots of watches with a round dial
conclusions
The union of modern technologies, such as the Intel Quark processor and the Android Wear operating system, opens up new opportunities not only for device developers, but also for application creators.
As you can see, an Android developer with experience in creating applications for smartphones and tablets can easily switch to programs for wearable computing devices such as smart watches. It is only necessary to take into account some features and you can get down to business.