can anybody give example how to开发者_运维知识库 implement click event in appwidget in android ?
Thanks
You can use RemoteViews.setOnClickPendingIntent(R.id.view_id, intent) method
for handle click event of app-widget. For more information you can refer below link
Click here
Use RemoteViews.setOnClickPendingIntent(R.id.view_id, intent) method. The intent parameter should be a well formed Intent object which would match on of the filters at your manifest file.
Intent intent = new Intent(context, Activity.class);
Uri widgetId = Uri.parse("" + appWidgetId); // this line means
intent.setData(widgetId); // you can send a widget id
PendingIntent pintent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.clickButtoninWidget, pintent);
return views;
精彩评论