nicolas2k / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
1 stars 0 forks source link

Foreground services #309

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be very helpful if services managing LiveCards were given Foreground 
status.

Original issue reported on code.google.com by keyboa...@gmail.com on 18 Dec 2013 at 3:30

GoogleCodeExporter commented 8 years ago
Hello,

Thanks for the feature request! Could you explain your use-case a bit more?

Best,
Alain

Original comment by ala...@google.com on 18 Dec 2013 at 4:54

GoogleCodeExporter commented 8 years ago
My particular case is that I have a LiveCard that shows current status of my 
Jenkins build machine, but this applies to any long-running service that would 
maintain a LiveCard (e.g. Music players, navigation, etc.). If my Service is 
killed to reclaim memory, the LiveCard would disappear for reasons that aren't 
clear to the user.

Currently the Service.startForeground(int, Notification) works for this 
purpose, but needing to create a Notification on a device that doesn't use them 
feels hackish and awkward. Additionally, since there's no way to verify that 
the Notification is valid, there is no way to know that the Service properly 
has Foreground priority (and thus won't be killed by the System).

The understanding behind Foreground Services is that killing the Service would 
be disruptive to the user. This criterion is certainly met in the case of a 
LiveCard-managing Service since it presents a UI.

Two possible approaches come to mind. The first is to add a 
startForeground(String, LiveCard) method which would function similarly to the 
existing startForeground(int, Notification) method. Another approach would be 
for the GlassHome app to bind to such Services, thus elevating them to the same 
priority level. The latter seems more conceptually appropriate (since the 
Service is effectively running on behalf of GlassHome), but I'm not certain 
what the API would look like.

Original comment by keyboa...@gmail.com on 19 Dec 2013 at 1:05

GoogleCodeExporter commented 8 years ago

Original comment by ala...@google.com on 19 Dec 2013 at 4:10

GoogleCodeExporter commented 8 years ago
This has been fixed as of XE16.

Original comment by ala...@google.com on 16 Apr 2014 at 3:49

GoogleCodeExporter commented 8 years ago
How was this fixed? I haven't seen anything in the GDK documentation that 
specifies how to ensure a LiveCard-hosting service has foreground status. Does 
this happen on its own?

Original comment by keyboa...@gmail.com on 16 Apr 2014 at 6:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
My apologies, you can achieve that by using the LiveCard#attach method:
  https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard#attach(android.app.Service)

This will set your Service as foreground until the LiveCard is unpublish.

Original comment by ala...@google.com on 16 Apr 2014 at 8:03