0 0

问一个关于android AppWidget的问题10

我比着AppWidget的例子抄了一遍代码,但代码没有运行。

在AndroidManifest.xml中我配置了receiver,并且相关的xml文件我都加上了
  <receiver android:name=".WordWidget" android:label="@string/app_name">
   <intent-filter>
    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
   </intent-filter>
   <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_word" />
  </receiver>

我建了一个AppWidgetProvider的子类WordWidget,如下:
public class WordWidget extends AppWidgetProvider {
private static final String TAG = "WordWidget_test";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  Log.d(TAG, "onUpdate");
  // 下面的内容我先注释掉,代码多了太乱,这里主要的问题是 没有执行到这一步
  // context.startService(new Intent(context, UpdateService.class));
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
  Log.d(TAG, "onDeleted");
}
@Override
public void onEnabled(Context context) {
  Log.d(TAG, "onEnabled");
}
@Override
public void onDisabled(Context context) {
  Log.d(TAG, "onDisabled");
}
}

其实WordWidget根本没有执行到,好像没有接收到这个事件android.appwidget.action.APPWIDGET_UPDATE,桌面上没有我要显示的组件。

请问各位大虾:是哪里没有配置好吧?能不能帮我解决一下?
2009年5月05日 22:29

1个答案 按时间排序 按投票排序

0 0

这个要你自己添加的。

2009年5月08日 10:04

相关推荐

Global site tag (gtag.js) - Google Analytics