Source:
public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) { ComponentName thisWidget = new ComponentName(context, WidgetProviderFeaturedPage.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); for (final int widgetId : allWidgetIds) { Log.d(TAG, "updating widget..."); final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_featured_page); (new FetchMainPageTask((WikipediaApp) context.getApplicationContext()) { @Override public void onFinish(List<Section> result) { if (result.size() == 0) { return; } Spanned text = Html.fromHtml(result.get(0).getContent()); URLSpan[] spans = text.getSpans(0, text.length(), URLSpan.class); String titleText = ""; for (URLSpan span : spans) { if (!span.getURL().startsWith("/wiki/") || (text.getSpanEnd(span) - text.getSpanStart(span) <= 1)) { continue; } PageTitle title = WikipediaApp.getInstance().getPrimarySite() .titleForInternalLink(Utils.decodeURL(span.getURL())); if (!title.isFilePage() && !title.isSpecial()) { titleText = title.getDisplayText(); break; } } if (!TextUtils.isEmpty(titleText)) { remoteViews.setTextViewText(R.id.widget_content_text, titleText); } appWidgetManager.updateAppWidget(widgetId, remoteViews); } @Override public void onCatch(Throwable caught) { Log.e(TAG, "Error while updating widget", caught); } }).execute(); Intent intent = new Intent(context, PageActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(PageActivity.EXTRA_FEATURED_ARTICLE_FROM_WIDGET, true); PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_container, pendingIntent); appWidgetManager.updateAppWidget(widgetId, remoteViews); } }

Target:
public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) { ComponentName thisWidget = new ComponentName(context, WidgetProviderFeaturedPage.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); for (final int widgetId : allWidgetIds) { Log.d(TAG, "updating widget..."); final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_featured_page); (new FetchMainPageTask(WikipediaApp.getInstance()) { @Override public void onFinish(List<Section> result) { if (result.size() == 0) { return; } Spanned text = Html.fromHtml(result.get(0).getContent()); URLSpan[] spans = text.getSpans(0, text.length(), URLSpan.class); String titleText = ""; for (URLSpan span : spans) { if (!span.getURL().startsWith("/wiki/") || (text.getSpanEnd(span) - text.getSpanStart(span) <= 1)) { continue; } PageTitle title = WikipediaApp.getInstance().getPrimarySite() .titleForInternalLink(Utils.decodeURL(span.getURL())); if (!title.isFilePage() && !title.isSpecial()) { titleText = title.getDisplayText(); break; } } if (!TextUtils.isEmpty(titleText)) { remoteViews.setTextViewText(R.id.widget_content_text, titleText); } appWidgetManager.updateAppWidget(widgetId, remoteViews); } @Override public void onCatch(Throwable caught) { Log.e(TAG, "Error while updating widget", caught); } }).execute(); Intent intent = new Intent(context, PageActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(PageActivity.EXTRA_FEATURED_ARTICLE_FROM_WIDGET, true); PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_container, pendingIntent); appWidgetManager.updateAppWidget(widgetId, remoteViews); } }