title: update multiple home screen widget from activity
body: <p>I have 2 widgets on my home screen. I know how to update the single widget from my Main activity. The following code updates my single widget when i press the back button on my Main activity.</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      Intent intent = new Intent(this, todo_widget.class);
      intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
      int[] ids = AppWidgetManager.getInstance(getApplication())
              .getAppWidgetIds(
                      new ComponentName(getApplication(),         todo_widget.class));
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      sendBroadcast(intent);}
  </code></pre>
  
  <p>But both the widgets are not updating  if i put my code like this :-</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      Intent intent = new Intent(this, todo_widget.class);
      intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
      int[] ids = AppWidgetManager.getInstance(getApplication())
              .getAppWidgetIds(
                      new ComponentName(getApplication(),     todo_widget.class));
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
      sendBroadcast(intent);
      Intent intent1 = new Intent(this, todo_widget2.class);
      intent1.setAction("android.appwidget.action.APPWIDGET_UPDATE");
      int[] ids1 = AppWidgetManager.getInstance(getApplication())
              .getAppWidgetIds(
                      new ComponentName(getApplication(), todo_widget2.class));
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids1);
      sendBroadcast(intent1);
      this.finish();
  }
  </code></pre>
  
  <p>please someone help me out of this. How do I update both the widgets when i press the back button or when my Main activity is created?</p>