Explain in detail how to use notification in Android

In message notification, we often use two controls notification and toast. Especially for important information and information that needs to be displayed for a long time, notification is the most appropriate. He can display an icon at the top to indicate that there is a new notice. When we pull down the notice bar, we can see the detailed notice content. The most typical applications are the display of missed messages and missed calls, as well as QQ wechat. We know that there is a missed call or missed message and receives QQ offline information. Similarly, we can also customize a notification to define the information our own program wants to convey.

Notification I have divided it into two types: one is the default display mode and the other is user-defined. Today I will tell you about the default display mode: 1. The program framework structure diagram is as follows

2. The source code of the layout file main.xml is as follows

3. The source code of mainactivity.java is as follows:

4. The source code of the layout file secondlayou.xml is as follows:

5. The source code of secondactivity.java is as follows:

6. The source code of notificationreceiver.java is as follows:

7. The running effect of the program is as follows:

The above is a detailed introduction to the use of notification in Android. I hope it will inspire your learning and help you better learn Android Software Programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>