0703-app-notification-statue-bar

Source: Internet
Author: User

1. Display Textticker and only icon two cases: when the parameter Showticker is true, the display does not appear

        In this sample, we'll use the same text for the ticker and the expanded notification        charsequence text = GetText (te Xtid);        Choose the ticker text        String Tickertext = showticker? getString (Textid): null;        Set the icon, scrolling text and timestamp        Notification Notification = new Notification (Moodid, Tickertext,                Sys Tem.currenttimemillis ());        Set the info for the "that" show in the notification panel.        Notification.setlatesteventinfo (This, GetText (r.string.status_bar_notifications_mood_title),                       text, Makemoodintent (Moodid));        Send the notification.        We use a layout ID because it is a unique number.  We use the It later to cancel.        Mnotificationmanager.notify (r.layout.status_bar_notifications, notification);    

2. Show create notifaction through Iew


  //Instead of the normal constructor, we ' re going to use the one with no args and fill   &nbsp ;   //In all of the data ourselves.  the normal one uses the default layout for notifications.        //You probably want, and cases, but if you want to do something custom, you& nbsp;      //can set the Contentview field to your own remoteviews OBJECT.  &NB sp;     Notification Notif = new Notification ();       // This was who should was launched if the user selects our notification.        notif.conte ntintent  = Pendingintent.getactivity (This, 0,                 New Intent (this, notificationdisplay.class)          SetFlags (Intent.flag_activity_new_task)  &NBsp;     . PutExtra ("Moodimg", Moodid), pendingintent.flag_update_current);        //In this sample, we'll use the same text for the ticker and the expanded NOTIFICATION&NBS p;       charsequence Text = GetText (Textid);         Notif.tickertext = text;
  

Notifacation Setting Sound and vibration

                This method sets the defaults on the notification before posting it.        This was who should was launched if the user selects our notification. Pendingintent contentintent = pendingintent.getactivity (this, 0, new Intent (This, statusbarnotifications.cl        ), 0); In this sample, we'll use the same text for the ticker and the expanded notification charsequence text = GetText        (R.string.status_bar_notifications_happy_message);  Final Notification Notification = new Notification (r.drawable.stat_happy,//The icon for the status Bar text,//The text to display in the ticker system.currenttimemil Lis ());                        The timestamp for the notification notification.setlatesteventinfo (this,                                  The context to use GetText (R.string.status_bar_notifications_mood_title),           The title for the notification text and//the details to display in the              Notification contentintent);                The contentintent (see above) notification.defaults = defaults; Mnotificationmanager.notify (r.layout.status_bar_notifications,///We use a string ID because it is a UN  Ique//number.                     We use it later to cancel the notification);        Notification}//The icon for the status bar Notif.icon = Moodid;        Our custom view remoteviews Contentview = new Remoteviews (Getpackagename (), R.layout.status_bar_balloon);        Contentview.settextviewtext (r.id.text, text);        Contentview.setimageviewresource (R.id.icon, Moodid);        Notif.contentview = Contentview;  We use a string ID of because is a unique number.   We use it later to cancel the     Notification mnotificationmanager.notify (r.layout.status_bar_notifications, Notif); 

Default values are: Notification.default_sound, Notification.default_vibrate, Notification.default_all




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.