title: Widgets don't respond when re-added through code
body: <p>I am working on a launcher. It let's users add widgets from the list, it works fine.
  I store information about the widget (PackageName, ClassName and it's co-ordinates on the screen) in my database when the user adds one to the screen.</p>
  
  <p>When the application is restarted (or the device itself) I add those (user selected) widgets back through code:</p>
  
  <pre><code>// APPWIDGET_HOST_ID is any number you like
  appWidgetManager = AppWidgetManager.getInstance(this);
  appWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);
  AppWidgetProviderInfo newAppWidgetProviderInfo = new AppWidgetProviderInfo();
  
  // Get an id
  int appWidgetId = appWidgetHost.allocateAppWidgetId();
  
  // Get the list of installed widgets
  List&lt;AppWidgetProviderInfo&gt; appWidgetInfos = new ArrayList&lt;AppWidgetProviderInfo&gt;();
  appWidgetInfos = appWidgetManager.getInstalledProviders();
  
  for(int j = 0; j &lt; appWidgetInfos.size(); j++)
  {
      if (appWidgetInfos.get(j).provider.getPackageName().equals(PackageName) &amp;&amp; appWidgetInfos.get(j).provider.getClassName().equals(ClassName))
      {
          // Get the full info of the required widget
          newAppWidgetProviderInfo = appWidgetInfos.get(j);
          break;
      }
   }
  
  // Create Widget
  AppWidgetHostView hostView = appWidgetHost.createView(this, appWidgetId, newAppWidgetProviderInfo);
  hostView.setAppWidget(appWidgetId, newAppWidgetProviderInfo);
  
  // Add it to your layout
  RelativeLayout widgetLayout = (RelativeLayout) findViewById(R.id.widgetLayout);
  widgetLayout.addView(hostView);
  </code></pre>
  
  <p>The widget is successfully added to the layout but it seems like it's not enabled/updated. It doesn't respond to clicks (for instance, Analog Clock) and doesn't show any data (for instance, Music player widget), although I have put this:</p>
  
  <pre><code>@Override
  protected void onStart() {
      super.onStart();
      appWidgetHost.startListening();
  }
  
  @Override
  protected void onStop() {
      super.onStop();
      appWidgetHost.stopListening();
  }
  </code></pre>
  
  <p>I am stuck on it since quite a long time. Searched a lot but it seems I'm the only one in this world with this problem.</p>