Notification class component
(1) Toast components: usually appear at the bottom of the screen, black border, showing a period of time automatically disappear, will not interrupt user action.
Scenario: Download complete, update complete, charging end, installation successful, etc.
Toast.maketext (This, "Download Done", Toast.length_short). Show ();
(2) Notification component: notifications on the status bar
Features: Notification with global effect, not strong timeliness.
Scene: SMS, missed calls, downloads, etc.
Get Notification Manager Notificationmanager Object
Mnitificationmanager = (Notificationmanager) getsystemservice (Context.notification_service);
Create a Notification object
Notification Notification = new Notification (r.drawable.xxx, "xxx", System.currenttimemillis ());
Set a specific jump
Intent Intent = new Intent (this,secondactivity.class);
Click to jump after setting the dropdown
Pendingintent pendingintent = pendingintent.getactivity (this,0,intent,0);
Setting the drop-down display
Notification.setlatesteventinfo (This, "10086", "arrears ...", pendingintent);
Send Notifications
Mnotificationmanager.notify (notifyid_1,notification);
Set the status bar notification to automatically disappear after clicking
Notification.flags = Notification.flag_auto_cancel;
Cancel Notification
Mnotification.cancel (notifyid_1); Clear notification with ID number notifyid_1
Mnotification.cancelall (); Clear all Notifications
Add permissions to the manifest file
Flash permission
Android.permission.FLASHLIGHT
Vibrator Permissions
Android.permission.VIBRATE
(3) Dialog Component: dialog box component
Scenario: Whether to exit, whether to install, whether to pay
Features: Interrupting user actions
Way One:
Get the object of Alertdialog construction class
Alertdialog.builder Bulider = new Alertdialog.builder (this);
Set some basic properties of the dialog box
Builder.settitle ("xxx");
Builder.setmessage ("xxx");
Add corresponding button options
Builder.setpositivebutton ("OK", null);
Builder.setnegativebutton ("Cancel", null);
Create an object of type Alertdialog
Alertdialog Alertdialog = Builder.create ();
Show dialog box
Alertdialog.show ();
Way two:
ShowDialog (int id);
overriding oncreatedialog (int id)
Date Time class component
(1) AnalogClock components
(2) DigitalClock components
(3) Timepickerdialog Time Selection dialog box
Get Calendar Object
Calendar calender = Calender.getinstance ();
Timepickerdialog Timepickerdialog = new Timepickerdialog (this,new Ontimesetlistener () {
@Override
public void Ontimeset (timepicker view, int hourofday, int minute) {
}
},calendar.get (Calender.hour), Calendar.get (Calendar.mimute), true);
Timepickerdialog.show ();
(4) Datepickerdialog Date selection dialog box
Datepickerdialog Datepickerdialog = new Datepickerdialog (this,new Ondatesetlistener () {
@Override
public void Ondateset (DatePicker view,int year,int monthofyear,int dayofmonth) {
}
},0,0,0);
Datepickerdialog.show ();