user386430
user386430

Reputation: 4967

android widget question

can anybody give example how to implement click event in appwidget in android ?

Thanks

Upvotes: 0

Views: 430

Answers (3)

JuHyun Lee
JuHyun Lee

Reputation: 139

        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;

Upvotes: 0

Dharmendra
Dharmendra

Reputation: 34026

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

Upvotes: 1

Konstantin Burov
Konstantin Burov

Reputation: 69238

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.

Upvotes: 0

Related Questions