Android: Custom launcher widgets calling Intent doesn't work -
what need
i'm developing custom android launcher company, installed on company's tablets , therefore won't published on store. it's grid widgets managed remotely (by background service we're creating), means app should decide widgets add or remove whenever user opens it.
what have
i'm using following code add widgets:
appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(getcontext()); appwidgethost appwidgethost = new appwidgethost(getcontext(), appwidget_host_id); appwidgethost.startlistening(); list<appwidgetproviderinfo> appwidgetinfos appwidgetinfos = appwidgetmanager.getinstalledproviders(); for(int j = 0; j < appwidgetinfos.size(); j++) { if (appwidgetinfos.get(j).provider.getpackagename().equals(widgetpackage)) { // allocates id int appwidgetid = appwidgethost.allocateappwidgetid(); // gets app widget info appwidgetproviderinfo appwidgetproviderinfo = appwidgetinfos.get(j); // creates widget appwidgethostview hostview = appwidgethost.createview(getcontext(), appwidgetid, appwidgetproviderinfo); hostview.setappwidget(appwidgetid, appwidgetproviderinfo); // insers view layout grid insertview(row, column, rowspan, columnspan, hostview); // break; } }
and works fine. widget shows , it's buttons respond user touch.
here's 1 of the widgets onupdate:
public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { // perform loop procedure each app widget belongs provider (int appwidgetid : appwidgetids) { // create intent launch exampleactivity intent launchappintent = new intent(context, mapactivity.class); pendingintent launchapp = pendingintent.getactivity(context, 0, launchappintent, 0); // layout app widget , attach on-click listener // button remoteviews views = new remoteviews(context.getpackagename(), r.layout.widget_layout); views.setonclickpendingintent(r.id.widget_layout, launchapp); // tell appwidgetmanager perform update on current app widget appwidgetmanager.updateappwidget(appwidgetid, views); } }
the problem
one of widgets (shown above) calls intent start it's fullscreen activity when clicked, , doesn't work on custom launcher, though works on default home launcher.
Comments
Post a Comment