3. Android Wear Libraries and Classes
The Android Wear APIs are delivered via Google Play services and the Android Support Library. This is a broad topic that's worth exploring in-depth, but there's a couple of libraries and classes that are worth getting acquainted with straight away.
Android Support Library & NotificationCompat
The easiest way to start developing for wearables is to create a handheld app that can send notifications to a paired wearable device.
Extending your notifications in this way requires several classes, which you can find in the Android v4 Support Library:
NotificationCompat.WearableExtender: This class allows you to add wearable-specific extensions to your notifications, which is essential for providing users with the best possible Android Wear experience.NotificationCompat.Builder: This builder class ensures your notifications display properly, both on handheld and wearable devices.NotificationManagerCompat: This class ensures your notifications properly support wearable features. When it's time to deliver your notifications, make sure you useNotificationManagerCompatinstead ofNotificationManager. If you do useNotificationManager, it's possible someNotificationCompat.WearableExtenderfeatures won't function properly.NotificationCompat.Action.WearableExtender: This class extends notification actions to wearables. Each action must have a title, an icon that represents the action, and an Intent that's sent whenever the user invokes the action.
To add the Android v4 Support Library to your development environment, open theAndroid SDK Manager, and then download and install either the Android Support Library package (if you’re an Eclipse user) or Android Support Repository (if you're on Android Studio).

Wearable User Interface Support Library
This unofficial library helps you design a wearable-friendly user interface for your app by including user interface widgets that illustrate best practices.
One particularly important component of this support library, is the BoxInsetLayoutlayout manager, which lets you use the same layout on both rectangular and round screens.
If you're using Android Studio, then this library is automatically included when you use the Project Wizard to create a wearable app.
Comments
Post a Comment