android - How to update widget manually? -


i want update widget manually. so, add in androidmanifest filter:

 <action android:name="com.myapp.widget_update"/> 

and try send broadcasts adb console

am broadcast -a com.myapp.widget_update 

but nothing happens. here code onreceive:

public class myapp extends appwidgetprovider {      private final static intentfilter intentfilter = new intentfilter("com.myapp.widget_update");      private final broadcastreceiver broadcastreceiver = new broadcastreceiver() {         public void onreceive(context context, intent intent) {             updatewidget(context);         }     }; } 

you have put 1 button in layout_wid.xml file.

in onupdate() have find id of button.and put click event refresh widget

intent imageview2intent= new intent(context, watchwidget.class); pendingintent pendingintent= pendingintent.getbroadcast(context,0, imageview2intent,0);          remoteviews.setonclickpendingintent(r.id.widget_textview, pendingintent); 

you try way.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -