Android Wear Development-card Notifications-section II: Custom Wear card styles

Source: Internet
Author: User

I. Preface description
Add the Android Wear notification feature in the previous section we have implemented a simple Android Wear card extension, but the default number of cards provided to us can only achieve a simple text display, if you want to customize the layout, add pictures and so on, you need the knowledge of this section.
Two. Environment Configuration
    1. Code configuration is no different from the previous section
    2. If you use the Wear simulator to develop, you must pay attention to the configuration, the use of the Host GPU must be hooked, otherwise, the dynamic custom card will not display, into a black block.

Three. Custom Cards

    1. Figure 1~4 Card display: can set the card height, can adjust the display content style
    2. Figure 5 Card display: Animation effect, here is actually a non-stop moving card

So we can see that the custom cards can do things that are many and many.

Code implementation
PrivateNotification Getcustomextender () {//1. Build a pendingintent that specifies activityIntent displayintent=NewIntent ( This, Secondactivity.class); Pendingintent displaypendingintent= Pendingintent.getactivity ( This,0, Displayintent, pendingintent.flag_update_current); //2. Build a wear extension object and set the pendingintent to show activityWearableextender Extender=NewNotificationcompat.wearableextender ();    Extender.setdisplayintent (displaypendingintent); //3. Build a Notificationcompat.builder, fill in the relevant parameters, and return the notification objectNotificationcompat.builder Builder=NewNotificationcompat.builder ( This); Builder.setcontenttitle ("title"); Builder.setcontenttext ("text");    Builder.extend (extender); returnbuilder.build ();}

It is then added to the card in the form of adding a new page card.

    Wearableextender.addpage (Getcustomextender ());

Android Wear Development-card Notifications-section II: Custom Wear card styles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.