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