Android Development notification Common settings method

Source: Internet
Author: User

Simple record notification on the Setup method, no example

 Progress notification Notificationmanager = (Notificationmanager) context.getsystemservice (Context.notifi            Cation_service);            Builder = new Notificationcompat.builder (context); Builder.setcontenttitle ("new version")//the caption displayed. Setcontenttext ("Downloading ...")//Displays the details. Setsmalli            Con (r.mipmap.ic_launcher);            Hint Text Builder.setticker ("You have a new message!");                    Click Cancel, Priority Builder.setautocancel (TRUE).            SetPriority (Notificationcompat.priority_default);            Builder.setdefaults (Notification.default_all);  Associated Pendingintent, click on the page to jump//pendingintent pendingintent = pendingintent.getactivity (this, 0,//New            Intent (this, mainactivity.class), 0);            Builder.setcontentintent ();            Specifies the view notification the normal state of the View//Builder.build (). Contentview=contentview;        The View//builder.build () when expanded. Bigcontentview = Expandview;      /* Prompt way Default_all: ringtones, flashes, vibrations are system default.            Default_sound: System default ringtone.            Default_vibrate: System default vibration.            Default_lights: System default Flash.            Other ways: Setsound (Uri sound): Set a ringtone to respond to notifications.            Pass a URI parameter in the form "File:///mnt/sdcard/Xxx.mp3".            setlights (int argb, int onms, int offms): Sets the blinking rate of the front LED lights, the number of milliseconds, and the number of milliseconds to pause.            Setvibrate (long[] pattern): Sets the mode of vibration, with a long array to hold the vibration of the millisecond interval. */* SetStyle () pass a Notificationcompat.style object, which is an abstract class, Android provides us with three implementation classes for displaying different scenarios.            are: Notificationcompat.bigpicturestyle, which displays a 256dp height bitmap in the detail section.            Notificationcompat.bigtextstyle, displays a large block of text in the detail section. Notificationcompat.inboxstyle, displays a line of text in the detail section. *///builder.setwhen ()///Set notification time, default current time

Send notification:

Update Progress            builder.setprogress ((int) l, (int) L1, true);            Send notification            notificationmanager.notify (Notificationflag, Builder.build ());
To cancel a notification:

Notificationmanager.cancel (Notificationflag);


Android Development notification Common settings method

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.