Jakub
Jakub

Reputation: 2141

How can I check which widget was clicked?

I need to show different data when the different widget will be clicked. For example widget one will show me activity with number 1 and widget to with numer 2 :)

Perhaps I can send some data by intent from widget, but then how to recive that data in activity class? Widget class

Intent intent = new Intent(context, Information.class);
        intent.putExtra("widget_id", appWidgetId);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget1x1);
        remoteViews.setOnClickPendingIntent(R.id.widget_layout, pendingIntent);

Upvotes: 0

Views: 266

Answers (1)

kosa
kosa

Reputation: 66637

Bundle extras = intent.getBundle();
String id = extras.getString("widget_id");

Upvotes: 2

Related Questions