Code example for AppWidgetManager

Methods: updateAppWidget

0
   
  @Override 
  public void onUpdate(Context ctxt, AppWidgetManager mgr,
                        int[] appWidgetIds) {
	    ComponentName me=new ComponentName(ctxt, AppWidget.class);
	    mgr.updateAppWidget(me, buildUpdate(ctxt, appWidgetIds));  
  } 
   
  private RemoteViews buildUpdate(Context ctxt, int[] appWidgetIds) {
    RemoteViews updateViews=new RemoteViews(ctxt.getPackageName(),
                                            R.layout.widget); 
   
   Intent i = new Intent(ctxt, Info.class);
   //i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
   //ctxt.startActivity(i); 
   PendingIntent pi = PendingIntent.getActivity(ctxt, 0, i, 0); 
     
   updateViews.setImageViewResource(R.id.station1,
                                     IMAGES.get(states[0]));    
   updateViews.setImageViewResource(R.id.station2,
                                   IMAGES.get(states[1]));