【发布时间】:2014-05-08 23:44:29
【问题描述】:
大家好,我对小部件完全陌生,我不知道如何在清单中声明小部件,每当我尝试时都会出错
小部件正在与已在清单中定义的服务通信
包名 包源.justanothermusicplayer.service;
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
RemoteViews controlButtons = new RemoteViews(context.getPackageName(),
R.layout.widget);
Intent playIntent = new Intent(Player.BROADCAST_PLAYPAUSE);//player is a class which starts the service
PendingIntent playPendingIntent = PendingIntent.getService(
context, REQUEST_CODE, playIntent, INTENT_FLAGS);
controlButtons.setOnClickPendingIntent(
R.id.bPlay, playPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, controlButtons);
}
}
【问题讨论】: