android - In Google Glass, Menu Items are not shown after XE 17.2 Update, any Solutions? -
this worked when glass in on xe12, have opened solution after 2 months , xe17 menu items not shown when tapped on live card, instead live card disappearing.
have updated gdk, have changed code support latest gdk sneak peek version 2 changes according (https://developers.google.com/glass/release-notes#xe12)
this code
public class menuactivity extends activity { private static final string tag = menuactivity.class.getsimplename(); private visionservice.visionbinder mvisionservice; private serviceconnection mconnection = new serviceconnection() { @override public void onserviceconnected(componentname name, ibinder service) { if (service instanceof visionservice.visionbinder) { mvisionservice = (visionservice.visionbinder) service; openoptionsmenu(); } // no need keep service bound. unbindservice(this); } @override public void onservicedisconnected(componentname name) { } }; private boolean mresumed; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); bindservice(new intent(this, visionservice.class), mconnection, 0); } @override protected void onresume() { super.onresume(); mresumed = true; openoptionsmenu(); } @override protected void onpause() { super.onpause(); mresumed = false; } @override public void openoptionsmenu() { if (mresumed && mconnection != null) { super.openoptionsmenu(); } } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); if (id == r.id.action_send) { mvisionservice.requestworkordercard(); finish(); return true; } else if (id == r.id.action_refresh) { mvisionservice.requesttopworkorders(); finish(); return true; } else if (id == r.id.action_finish) { stopservice(new intent(this, visionservice.class)); finish(); return true; } else { return super.onoptionsitemselected(item); } } @override public void onoptionsmenuclosed(menu menu) { super.onoptionsmenuclosed(menu); } }
this error getting
.windowmanager$badtokenexception: unable add window -- token null not valid; activity running?
and log(not error) too
rebinding view mis-matched type: com.google.glass.home.timeline.timelineapiadapter
it great if body on this. thank you
you need change way menu gets opened xe 16 or 17. below code works:
public class menuactivity extends activity { private boolean mattachedtowindow; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public void onattachedtowindow() { super.onattachedtowindow(); mattachedtowindow = true; openoptionsmenu(); } @override public void ondetachedfromwindow() { super.ondetachedfromwindow(); mattachedtowindow = false; } @override public void openoptionsmenu() { if (mattachedtowindow) { super.openoptionsmenu(); } } @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.main, menu); return true; } ... } public class appservice extends service { private static final string tag = "appservice"; private static final string live_card_id = "helloglass"; private appdrawer mcallback; private livecard mlivecard; @override public void oncreate() { super.oncreate(); } @override public ibinder onbind(intent intent) { return null; } @override public int onstartcommand(intent intent, int flags, int startid) { if (mlivecard == null) { mlivecard = new livecard(this, live_card_id); mcallback = new appdrawer(this); mlivecard.setdirectrenderingenabled(true).getsurfaceholder().addcallback(mcallback); intent menuintent = new intent(this, menuactivity.class); mlivecard.setaction(pendingintent.getactivity(this, 0, menuintent, 0)); mlivecard.publish(publishmode.reveal); } return start_sticky; } ... }
also, gdk samples stopwatch , timer (https://developers.google.com/glass/samples/gdk) have menu-related code works well.
Comments
Post a Comment