我实现了小部件,代码如下所示
@Override
public void onCreate() {
Log.d("MYDAYS", "--- widget update oncreate--");
Intent intent = new Intent(this, UpdateWidgets.class);
extras = intent.getExtras();
}
@Override
//public void onStart(Intent intent, int startId) {
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("MYDAYS", "--- widget update onstartcommand--");
String onlythatwidgetstr = "";
if (extras != null) {
// Log.d("MYDAYS", "--- in getExtras");
onlythatwidgetstr = extras.getString("widgettableid");
if (onlythatwidgetstr == null)
onlythatwidget
非常奇怪的是,首次安装后,小部件说有一个加载问题。只有在我第一次安装后重新安装应用程序后,小部件才会按预期显示!任何想法?