android - Open Activity with setPendingIntentTemplate -


i'm doing widget 1 stackview i'm adding bitmaps(images) inside remoteviewfactory.

my problem when want onclickpendingintent() each image (that have inside stackview). know have use setpendingintenttemplate() instead, don't know how go activity when press widget's image.

then have inside onupdate() widget class create 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 have in remoteviewsfactory class handle 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, fillinintent.putextra(intent.extra_text, images.get(index).gettitle()); acting phone showing me "use complete actions" can choose app want open, if see i'm putting in putextra() string. want open activity , pass putextra() image (images.get(index).getimage()) bitmap

i figured out wrong:

intent templateintent = new intent(context, activity_i_want_to_open.class); templateintent.putextra(appwidgetmanager.extra_appwidget_id, appwidgetid);     pendingintent templatependingintent = pendingintent.getactivity(             context, 0, templateintent, 0); 

then, didn't need flag_update_current, because want updating nothing.

and in remoteviews side:

intent fillinintent = new intent(); rv.setonclickfillinintent(r.id.image, fillinintent); 

i didn't need putextra() because i'm not sending data other activity.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -