An intent is something that is used right now; A pendingintent is something that may create an intent in the future. You will use a pendingintent with notifications, alarmmanager, etc.
Notification n = new notification (R. drawable. face_1, "Service Startup", system. currenttimemillis (); pendingintent contentintent = pendingintent. getactivity (this, 0, new intent (this, tserviceholder. class), 0); N. setlatesteventinfo (this, "task title", "task content", contentintent); nmanager. Y (ication_id _id, n); // start the taskbar
String MSG = "Hello, beautiful girl"; string number = "187 *** 5477"; smsmanager SMS = smsmanager. getdefault (); pendingintent Pi = pendingintent. getbroadcast (smsactivity. this, 0, new intent (...), 0); SMS. sendtextmessage (number, null, MSG, PI, null); // broadcast intent to toast after the message is sent successfully. maketext (smsactivity. this, "sent successfully", toast. lenght_long ). show ();
By giving a pendingintent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself, it is equivalent to pendingintent representing the intent
Description of parameters in the smsmanager. sendtextmessage (string destinationaddress, string scaddress, string text, pendingintent sentintent, pendingintent deliveryintent) function:
1) pendingintent sentintent: if the message is sent successfully, sendintent broadcasts the intent of its internal description. Otherwise, an error code is generated and sent to Android. app. pendingintent. onfinished callback. It is best not to leave this parameter blank, otherwise there may be potential problems of resource waste;
2) pendingintent deliveryintent: The pendingintent broadcast that is performed after the message has been delivered to the recipient.
View the pendingintent class. You can see many send functions, that is, pendingintent is performing related operations.
========================================================== ==============================================
Intent indicates a purpose, the first parameter indicates the class, and the second parameter indicates the target class.
Pendingintent is the description of an intent.
Differences between pendingintent and intent:
Pendingintent is an intent description. We can give this description to another program. Other programs will do what you want to do at the rest of the time according to this description.
Intent literally means intent, that is, our purpose. What we want to do can be executed immediately in activity.
Pendingintent is equivalent to packaging intent. We don't have to execute it immediately. We wrap it and pass it to another activity or application.
At this time, the pendingintent application can be obtained based on the intent to learn the intent of the sender, choose to block or continue to pass or execute