Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open an application from widget in Android?

When we click the widget at that time I need to open an activity screen (or application). How to do this?

like image 509
RMK Avatar asked Aug 28 '10 06:08

RMK


1 Answers

You need to set an onClickpendingIntent on your widget

Intent intent = new Intent(context, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);

Check this out

Processing more than one button click at Android Widget

like image 106
DeRagan Avatar answered Oct 05 '22 22:10

DeRagan