From: http://blog.csdn.net/xuzhuang2008/archive/2011/04/13/6321477.aspx
Java code
1. Notification n = new notification (R. drawable. face_1, "service started", system. currenttimemillis ());
2. pendingintent contentintent = pendingintent. getactivity (this, 0, new intent (this, tserviceholder. Class), 0 );
3. N. setlatesteventinfo (this, "task title", "task content", contentintent );
4. nmanager. Y (icationication_id, n); // start the taskbar
Differences between pendingintent and intent: 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.
1. Example of Android text message sending in GSM network
(1) code excerpt
Java code
1. String MSG = "Hello, beautiful girl ";
2. String number = "135 *** 6784 ";
3. smsmanager SMS = smsmanager. getdefault ();
4.
5. pendingintent Pi = pendingintent. getbroadcast (smsactivity. This, 0, new intent (...), 0 );
6. SMS. sendtextmessage (number, null, MSG, PI, null );
7. Toast. maketext (smsactivity. This, "sent successfully", Toast. lenght_long). Show ();
(2) code explanation
Pendingintent is an intent description. We can give this description to other programs, other programs will do what you want to do at the rest of the time according to this description (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 ). In this example, other programs send text messages. After the messages are sent successfully, intent should be broadcast.
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.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/xuzhuang2008/archive/2011/04/13/6321477.aspx