title: Update Android Widget From Activity
body: <p>I have a widget, its setup so that when I click on it, it opens some settings in an activity. </p>
  
  <pre><code>views.setOnClickPendingIntent(R.id.btnActivate, pendingIntent);
  </code></pre>
  
  <p>This configures some settings for the application. What I want to achieve is to have the widget update its view to reflect the changed settings when the Activity I launch closes. Using the update interval or any other type of polling isn't appropriate for this. </p>
  
  <p>I've seen a couple places here and in the android docs this code used:</p>
  
  <pre><code>appWidgetManager.updateAppWidget(mAppWidgetId, views);
  </code></pre>
  
  <p>But I don't know how to get the mAppWidgetId value. I tried following the example for a widget configuration activity here <a href="http://developer.android.com/guide/topics/appwidgets/index.html" rel="noreferrer">http://developer.android.com/guide/topics/appwidgets/index.html</a>, but in the following code, </p>
  
  <pre><code>    Intent intent = getIntent();
  Bundle extras = intent.getExtras();
  if (extras != null) {
      mAppWidgetId = extras.getInt(
              AppWidgetManager.EXTRA_APPWIDGET_ID, 
              AppWidgetManager.INVALID_APPWIDGET_ID);
  }
  </code></pre>
  
  <p>extras is always null, so I never get the AppWidgetID.</p>
  
  <p>Ok, now I'm just rambling. What do you think I can do?</p>