我只想知道是否必须在清单中声明一个扩展服务的类?
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name="com.cherise.readerwidget.MyWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
<service
android:name="com.cherise.readerwidget.UpdateWidgetService"
android:enabled="true"
android:exported="true" >
</service>
</application>
在这个类中,我有一个执行 HttpConnections 的 AsyncTask。
它似乎没有在帖子执行中更新我的小部件。
请帮忙
protected void onPostExecute(String details)
{
for(int widgetId : allWidgetIds)
{
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget_layout);
//remoteViews.setTextViewText(R.id.update, news.get(0).getTitle());
remoteViews.setTextViewText(R.id.update, "Bloemfontein: " + details + " F");
Intent clickIntent = new Intent(getApplicationContext(), MyWidgetProvider.class);
clickIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.update, pendingIntent);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
stopSelf();
}