Pendingintent, the intention to be determined, the intention of waiting
Website Link:http://developer.android.com/reference/android/app/PendingIntent.html
Official website regarding the inheritance of this class, pendingintent inherits from object. Because the class is final, there are no subclasses and cannot be inherited.
To get a Pendindintent object, you need to use the static method of the method class Getactivity (context, int, Intent, int), getactivities (context, int, intent[], int), Getbroadcast (context, int, Intent, int), GetService (context, int, Intent, int)
These static methods correspond to the behavior of intent, and jump to Activity,activities,broadcast,service.
The parameters of the 4 static methods are the same, where the first and third parameters are more important, followed by the second and fourth. The first parameter is passed into the current context, and the third parameter is passed into intent.
Pendingintent is a special intent, the main difference is that intent is executed immediately, pendingintent is to be determined intent. The pendingintent operation is actually the operation of the incoming intent.
The purpose of using pendingintent is primarily for the inclusion of intent execution to satisfy certain conditions.
Main place: Notification,smsmanager,alarmmanager, etc.
1.Notification Example:
1Notificationcompat.builder Mbuilder =NewNotificationcompat.builder ( This)2 Mbuilder.setsmallicon (R.drawable.notification_icon)3Mbuilder.setcontenttitle ("My notification")4Mbuilder.setcontenttext ("Hello world!");5Intent resultintent =NewIntent ( This, Resultactivity.class);6Pendingintent resultpendingintent = pendingintent.getactivity ( This, 0, resultintent,pendingintent.flag_update_current);7 mbuilder.setcontentintent (resultpendingintent);8 intMnotificationid = 001;9 //Gets An instance of the Notificationmanager serviceTenNotificationmanager mnotifymgr =(Notificationmanager) Getsystemservice (notification_service); One //Builds the notification and issues it. AMnotifymgr.notify (Mnotificationid, Mbuilder.build ());
2.SmsManager Example:
1 smsmanager smsmanage = Smsmanager.getdefault (); 2 Intent intent= 3 pendingintent pendingintent=pendingintent.getbroadcast ( Getapplicationcontext (), 0, intent, 0 4 smsmanage.sendtextmessage ("13xxxxxxxxx", Null , "This is a text message", Pendingintent, null );
Main constants
flag_cancel_current: If an identical pendingintent object already exists in the current system, the existing pendingintent will be canceled before a Pendingintent object is regenerated.
flag_no_create: If the same Pendingintent object does not exist in the current system, the system will not create the Pendingintent object and return null directly.
flag_one_shot: The pendingintent only works once. After the Pendingintent object is triggered by the Send () method, Pendingintent will automatically call cancel () to destroy, and if you call the Send () method again, the system will return a sendintentexception.
flag_update_current: If there is a pendingintent equivalent pendinginent that you describe in the system, then the Pendingintent object will be used by the system. However, the new intent is used to update the intent object data in the previous pendingintent, such as extras in the update intent.
Please refer to: http://blog.csdn.net/hudashi/article/details/7060837
The use of Android development pendingintent