android - How to get the appwidget layout associated with a appwidget ID -


i want appwidget layout associated appwidget id.

in widget provider class appwidget, android docs provide easy way appwidget ids...

public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) {     final int n = appwidgetids.length;     // perform loop procedure each app widget belongs provider     (int i=0; i<n; i++) {         int appwidgetid = appwidgetids[i]; 


ids dont allow me know appwidget provider comes (multiple widget providers , layouts.).

edit: using service class update widgets, not widget provider class.

in service class, want appwidget layout each id can use remoteviews update layout. have tried few different suggestions, none of them give me value need use remoteviews. eg "r.id.widget_layout"

how can value "r.id.widget_layout" appwidget id in correct "int" form use remoteviews?

you can appwidget layout id , info provider each appwidget way:

@override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) {     final int n = appwidgetids.length;      for(int i=0; i<n; i++) {          int appwidgetid = appwidgetids[i];          // can use layoutid variable instead of r.id.widget_layout         int layoutid = appwidgetmanager.getappwidgetinfo(appwidgetid).initiallayout;         // string yourprovider .widgetprovider2x2         string yourprovider = appwidgetmanager.getappwidgetinfo(appwidgetid).provider.getshortclassname();      }  } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -