Service outlives parent application on Google Glass?
Asked Answered
C

1

7

I have a service that is running in the same process.

    <service
        android:name=".service.GlassService"
        android:exported="true"
        android:label="@string/app_name" />

I start the service using startService().

        startService(new Intent(this, GlassService.class));

When I swipe down and exit the application, service lives on. When I kill it from DDMS, service is restarted, calling service with START_STICKY nor START_NOT_STICKY don't make a difference.

The only way I can stop service is when I explicitly call stopService() or stopItself() or omitting startService().

This is not the case on other android devices. Is this behavior typical for Google Glass ?

Chane answered 19/3, 2014 at 10:5 Comment(0)
S
1

That is typically why people use services. They are long running processes that are usually used to do background processing or for syncing data from a content provider. So it's easily an extension, that they can outlive their parent process.

Source:

  1. What you describe happens to my application too and it's run on a Normal Phone
  2. Says so in this Google documentation[docs][1] (Read the part about why services aren't a thread)

    [1]: http://developer.android.com/reference/android/app/Service.html

Sibylle answered 20/3, 2014 at 11:53 Comment(2)
On our non glass devices, service was always killed when we exited application (onDestroy() was called) no matter what we did. Our understanding was that service implicitly runs in same process (is not isolated) as application, so when application is killed service dies. I din't find anything about service outliving application in the reference you have posted. Could you explicitly point out the part you were talking about ?Chane
There is no expected behavior difference between Glass and non-Glass Service lifespan. What do you mean "when we exited [the] application"? Can you please be more specific about what you mean by this on glass and non-glass? An "Application" only ends when all Activity/Fragment/Service/Threads are stopped. Hitting the back button or swiping down should not exit the "Application" if a service is still running. Is it possible your Live Card service implementation is different than your non-Glass app's service implementation?Calabrese

© 2022 - 2024 — McMap. All rights reserved.