When we use it ourselves Notification When a message is prompted in the notification bar , We click on the drop-down message , To open it app Specified page , If more information is needed , It can be done through PendingIntent.

In use , There are some problems , Mainly parameters FLAG_CANCEL_CURRENT and FLAG_UPDATE_CURRENT, The summary is as follows :

PendingIntent There is one getActivity method , The first parameter is the context , There's nothing to say , Second parameter  requestCode, This one says at the back , The third parameter is
Intent, Used to store information , The fourth parameter is the operation identifier for the parameter , It is commonly used FLAG_CANCEL_CURRENT and FLAG_UPDATE_CURRENT.


PendingIntent.getActivity(context, 0,
notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT Time );

FLAG_UPDATE_CURRENT Will be updated before PendingIntent
News of , such as , You pushed the message 1, And in it Intent in putExtra Has a value “ABC”, Before clicking the message , Continue pushing the second message , And in it Intent in putExtra Has a value “CBA”, okay , At this time , If you click on a message 1 Or news 2, You'll find out , Both of them Intent All the information read from the “CBA”, That is to say , The second replaces the first


It's still the procedure above , You'll find out at this point , Click on the message 1 Time , No response , The second one can be click .

The reason for the above two problems lies in the second parameter requestCode, When requestCode When the value is the same , The latter will work on previous messages , So in order to avoid affecting the previous information ,requestCode Set different content each time .

©2019-2020 Toolsou All rights reserved,
What are the protection measures for website security ? Talking about uni-app Page value transfer problem Remember once EventBus Project issues caused by memory leaks I've been drinking soft water for three years ? What is the use of soft water and water softener Time conversion front desk will 2020-07-17T03:07:02.000+0000 Into 2020-07-17 11:07:02 Chuan Shen Count the number of letters (java Language implementation ) Time format 2020-01-13T16:00:00.000Z Medium T and Z What do they mean , How to deal with it msf Generate Trojan horse attack android mobile phone The world's first free open source ERP Odoo Ubuntu The best development environment What's the difference in server prices ?