user interface - Detect 'home button pressed' event in android service displaying a UI (similar to facebook chatheads) -
in facebook chatheads, part of facebook messenger app, noticed following behavior: far can see, chat head , opened chat screen parts of service. no activity involved.
how can sure? after press home on opened chat screen, gets minimized chat head, , can reopen chat screen. if chat screen activity, reopening activity via startactivity(intent)
after home button pressed, delay start of activity, specified here: starting activity service after home button pressed without 5 seconds delay
and here: reason 5 sec delay show activity on pressing home button?
in service oncreate method, use following code display ui service:
public class servicetest extends service { ... @override public void oncreate() { super.oncreate(); windowmanager = (windowmanager) getsystemservice(window_service); windowmanager.layoutparams params = new windowmanager.layoutparams( windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.type_phone, windowmanager.layoutparams.flag_not_focusable, pixelformat.translucent); windowmanager.addview(someview, params); } .... }
does have idea how can receive 'home button pressed' event directly service displaying ui? minimize view (similar facebook chat heads) when user presses home button.
well after doing own research issue, i've came following conclusions:
facebook "intercepting" navigation buttons providing flag type_system_overlay
attribute. on this post answer provided @jawsware
doing advices not - lead "affect" of controling navigation buttons
using flag provides focus on overlay, , takes focus activity behind.
with onfocuschangedlistener
view callback or onkey listener reacts closing full screen mode of overlay.
that's explains how reacts 3 navigation buttons - home / / recent tasks
Comments
Post a Comment