In Appwidget, ImageButton and button are supported controls, and their events can be divided into three types:
First, open activity 
Second, start Service 
Iii. Send button Action 
below begins an analysis of how it is implemented.  
First, open Activity 
1. First define a Intent that starts the activity;
eg:intent intent=new Intent (This, Fullscreen.class);  
to pass data, use the Intent.putextra () method  
Eg:intent.putExtra ("Iscircle", iscircle);  
2, instantiate a pendingintent with intent, invoke Pendingintent's Getacticity method to start another activity  
① If the intent has data, you need to set the value of the last parameter to: Flag_cancel_current 
eg:
Pendingintent pintent=pendingintent.getactivity (this, 0,intent,pendingintent.flag_cancel_current);
② If the intent does not have data, the last parameter is set to 0
Eg:pendingintent pfullintent=pendingintent.getactivity (this, 0, fullintent, 0);
3. Instantiate the RemoteView, which corresponds to the corresponding widget layout
Eg:remoteviews views= newremoteviews (Getpackagename (), r.layout.widget);
4. Set button events on RemoteView or ImageButton
Eg:views.setOnClickPendingIntent (r.id.ibfullscreen,pfullintent);
5. Update Appwidget interface
① If the Appwidget interface is updated within the OnUpdate () method
Eg:appWidgetManager.updateAppWidget (Appwidgetids, ActivityView);
② If you are updating the Appwidget interface outside of the OnUpdate () method (typically within a service), you need to define several variables
Eg:public remoteviews Views;//remoteview Object
Publiccomponentname Thiswidget; Component Name
Public Appwidgetmanager Manager; Appwidget Manager
Thiswidget = new ComponentName (this,pictureappwidgetprovider.class);
Manager = Appwidgetmanager.getinstance (this);
Manager.updateappwidget (Thiswidget, views);
Second, open service
1. Define a intent to open the service
Eg:intent startserviceinten=newintent ("Zyf.temp.Service.START");
Note: The parameter is a service-enabled action
2, using intent to instantiate a pendingintent, using Pendingintent GetService method to start a service
Eg:pendingintent pintent=pendingintent.getservice (context, 0, Startserviceinten, 0);
3. Instantiate the RemoteView, which corresponds to the corresponding widget layout
Eg:remoteviews views= newremoteviews (Getpackagename (), r.layout.widget);
4. Set button events on RemoteView or ImageButton
Eg:views.setOnClickPendingIntent (r.id.ibfullscreen,pfullintent);
5. Update Appwidget Interface
① if the Appwidget interface is updated within the OnUpdate () method
Eg:appWidgetManager.updateAppWidget (Appwidgetids, ActivityView);
② If you are updating the Appwidget interface outside of the OnUpdate () method (typically within a service), you need to define several variables
Eg:
Public Remoteviews Views;//remoteview Object
Publiccomponentname Thiswidget; Component Name
Public Appwidgetmanager Manager; Appwidget Manager
Thiswidget = new ComponentName (this,pictureappwidgetprovider.class);
Manager = Appwidgetmanager.getinstance (this);
Manager.updateappwidget (Thiswidget, views);
Third, send button action
1. Define a intent to send the button action
Eg:intent previnten=new Intent ("PREV");
2, using intent to instantiate a pendingintent, using Pendingintent Getbroadcast method to send the broadcast
Eg:pendingintent Pprevintent=pendingintent.getbroadcast (this, 0, Previnten, 0);
3. Instantiate the RemoteView, which corresponds to the corresponding widget layout
Eg:remoteviews views= newremoteviews (Getpackagename (), r.layout.widget);
4. Set button events on RemoteView or ImageButton
Eg:views.setOnClickPendingIntent (r.id.ibprev,pprevintent);
5. Update Appwidget interface
① If the Appwidget interface is updated within the OnUpdate () method
Eg:appWidgetManager.updateAppWidget (Appwidgetids, ActivityView);
② If you are updating the Appwidget interface outside of the OnUpdate () method (typically within a service), you need to define several variables
Eg:public remoteviews Views;//remoteview Object
Publiccomponentname Thiswidget; Component Name
Public Appwidgetmanager Manager; Appwidget Manager
Thiswidget = new ComponentName (this,pictureappwidgetprovider.class);
Manager = Appwidgetmanager.getinstance (this);
Manager.updateappwidget (Thiswidget, views);
6. Receive the action
① received within Appwidget's own OnReceive method
⒈ in action, to add action in Manifest.xml
Eg: <intent-filter>
<actionandroid:name= "Android.appwidget.action.APPWIDGET_UPDATE" ></action>
<actionandroid:name= "PREV" ></action>
</intent-filter>
⒉ writing the action to be implemented within the OnReceive () method
Eg:if (Intent.getaction (). Equals ("PREV"))&NBSP;
{&NBSP;
// The action to be implemented after this action is written &NBSP;
}
② receives within the service;
⒈ registers a broadcastreceive, declares the receiver &NBSP;
Eg:intentfilter filter=new intentfilter (); Filter.addaction ("PREV"); Registerreceiver (DoCommand, filter); ⒉, write the action to be implemented within the OnReceive method of the Broadcastreceive class &NBSP;
Eg:if ( Intent.getaction (). Equals ("PREV")) &NBSP;
{ &NBSP;
//The action to be implemented after this action is received to }
Appwidget Deep----button Event pass-through