title: Why the base class onReceive() function doesn't call the onUpdate()?
body: <p>I have a fairly simple home screen widget application that shows a Toast on a button click. On fortunately it display a Toast only on a power-up (or just after I update the apk in the emulator). The button click has a pending intent that send a ACTION_APPWIDGET_UPDATE but the onReceive() function of the base class doesn't handle it.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public class WordWidget extends AppWidgetProvider {
  
      @Override
      public void onReceive(Context ctxt, Intent intent) {
  
          Log.d("WordWidget.onReceive", "onReceive");
          Log.d("WordWidget.onReceive", intent.getAction());
  
          if (intent.getAction()==null) {
              ctxt.startService(new Intent(ctxt, UpdateService.class));
          } else {
              super.onReceive(ctxt, intent);
          }
      }
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  
          // To prevent any ANR timeouts, we perform the update in a service
          Log.d("WordWidget.onUpdate", "onUpdate");
  
          context.startService(new Intent(context, UpdateService.class));
      }
  
      public static class UpdateService extends Service {
          @Override
          public void onStart(Intent intent, int startId) {
              Log.d("UpdateService.onStart", "onStart");
  
              // Build the widget update for today
              RemoteViews updateViews = buildUpdate(this);
  
              // Push update for this widget to the home screen
              ComponentName thisWidget = new ComponentName(this, WordWidget.class);
              AppWidgetManager manager = AppWidgetManager.getInstance(this);
              manager.updateAppWidget(thisWidget, updateViews);
          }
  
          public RemoteViews buildUpdate(Context context) {
  
              Log.d("UpdateService.buildUpdate", "buildUpdate");
  
              RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_word);
  
              Intent defineIntent = new Intent(context, WordWidget.class);
              defineIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  
              PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, defineIntent, 0);
  
              updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent);
  
              showToast(context);
  
              return updateViews;
          }
  
          private void showToast(Context context){
              Log.d("UpdateService.showToast", "showToast");
              Toast.makeText(context, "It is working...", Toast.LENGTH_LONG).show();          
          }
  
          @Override
          public IBinder onBind(Intent intent) {
              // We don't need to bind to this service
              return null;
          }
      }
  }
  </code></pre>
  
  <p>On a power-up (or just after being re-installed) my widget shows the Toast, here's the LogCat:</p>
  
  <pre><code>01-17 13:03:10.855: I/ActivityManager(72): Start proc com.example.android.simplewiktionary for broadcast com.example.android.simplewiktionary/.WordWidget: pid=564 uid=10036 gids={3003}
  01-17 13:03:11.045: D/WordWidget.onReceive(564): onReceive
  01-17 13:03:11.045: D/WordWidget.onReceive(564): android.appwidget.action.APPWIDGET_UPDATE
  01-17 13:03:11.054: D/WordWidget.onUpdate(564): onUpdate
  01-17 13:03:11.075: D/UpdateService.onStart(564): onStart
  01-17 13:03:11.075: D/UpdateService.buildUpdate(564): buildUpdate
  01-17 13:03:11.094: D/UpdateService.showToast(564): showToast
  01-17 13:03:12.655: D/dalvikvm(72): GC_EXPLICIT freed 971K, 47% free 13550K/25159K, paused 7ms+52ms
  </code></pre>
  
  <p>Now once started, if I click on the button, here's the LogCat:</p>
  
  <pre><code>01-17 13:04:16.095: D/dalvikvm(126): GC_EXPLICIT freed 72K, 14% free 14016K/16135K, paused 3ms+3ms
  01-17 13:04:16.277: D/WordWidget.onReceive(564): onReceive
  01-17 13:04:16.277: D/WordWidget.onReceive(564): android.appwidget.action.APPWIDGET_UPDATE
  01-17 13:04:21.365: D/dalvikvm(564): GC_EXPLICIT freed 71K, 5% free 6307K/6595K, paused 3ms+2ms
  </code></pre>
  
  <p>As you can see the onUpdate() is not called by the onReceive() base class function...</p>
  
  <p>Could you help me with this?</p>
  
  <p>Thanks.</p>