I'm doing a widget with one stackView which i'm adding bitmaps(images) inside with a RemoteViewFactory.
My problem is when I want to do a onClickPendingIntent()
for each image (that I have inside the stackView). I know I have to use setPendingIntentTemplate()
instead, but I don't know how to go to an Activity when I press some widget's image.
Then this is what I have inside onUpdate()
from widget class to create the Pending Intent Template:
Intent templateIntent = new Intent(Intent.ACTION_VIEW);
templateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent templatePendingIntent = PendingIntent.getActivity(
context, 0, templateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setPendingIntentTemplate(R.id.widget_stack_view,
templatePendingIntent);
And this is what I have in a RemoteViewsFactory class to handle the Pending Intent Template:
public RemoteViews getViewAt(int index){
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.grid_item_layout);
rv.setImageViewBitmap(R.id.image, images.get(index).getImage());
Intent fillInIntent = new Intent();
fillInIntent.putExtra(Intent.EXTRA_TEXT, images.get(index).getTitle());
rv.setOnClickFillInIntent(R.id.image, fillInIntent);
return rv;
}
So far, this fillInIntent.putExtra(Intent.EXTRA_TEXT, images.get(index).getTitle());
is acting with the phone showing me a "use complete actions" where you can choose with which app you want to open, but if you see what i'm putting in the putExtra()
is a String. But what I want is open a Activity and then pass with putExtra()
a image (images.get(index).getImage()
) that is a bitmap
Aucun commentaire:
Enregistrer un commentaire