I am using an AppWidgetProvider and attempting to override the onEnabled which I assume is what is called when the app gets added to the home screen from the user. My AppWid
The buildRemoteViews() method isn't how you get a RemoteViews object in a widget; use a constructor instead.
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
No offense, but this is pretty clearly laid in the example in the API guide for App Widgets.
Register for the broadcast in your manifest:
<receiver android:name="MyWidget" android:label="Widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.APPWIDGET_ENABLED" />
</intent-filter>
....
</receiver>
Also note this about onEnabled():
"This is called when an instance the App Widget is created for the first time. For example, if the user adds two instances of your App Widget, this is only called the first time."
You also have the fact that onUpdate() will be called anyway when an instance is added, so doing the same thing in onEnabled() may be redundant.
Also, once you get that AsyncTask to execute, you're going to have a host of problems, first of which is the Context object is not an Activity.
EDIT: Now that your method is being called, you will need to set the text using RemoteViews. You don't need to do it in onPostExecute() since this is cross-process update.
protected Void doInBackground(String... arg0) {
String beerText = readJSONFeed(arg0[0]);
AppWidgetManager mgr = AppWidgetManager.getInstance(c);
int[] appWidgetIds = mgr.getAppWidgetIds(new ComponentName(c, HelloWidget.class));
//You need a static method somewhere (I usually put in widget provider class)
//that builds the RemoteView and sets everything up.
RemoteViews rv = HelloWidget.buildRemoteViews(c, mgr, appWidgetIds);
rv.setTextViewText(R.id.text_view_in_layout, beerText);
mgr.updateAppWidget(appWidgetIds, rv);
}
That will update all your AppWidget's, if you only want one to update, you will need to pass in it's id.