[aerogear-dev] Pipes in the event of application interruption. AKA We're doing it wrong.

Summers Pittman supittma at redhat.com
Tue Feb 5 12:33:39 EST 2013


What happens if a Pipe is running a call to the server (let's say a read) and the application is put in the background? (IE a phone call comes in).

On Android the answer is a big it depends on the application and there is nothing the developer can do about it.  On iOS the answer seems to be the same.  We need to fix the "there is nothing the developer can do about it".

My general proposal (I am working on a more specified one) is for Pipe to provide hooks into its running requests so the application can register itself as a listener.

In Android it will look like this (pseudocode)
https://gist.github.com/secondsun/a7a92eea911884071aea

Here the Pipe returns an identifier of the thread which is running.  When you call read you pass in a listener which will handle the response.  The Activity is responsible for managing the life cycle of the listener in relation to its own.  If if the Activity is put in the background it should not listen for responses.

I don't like this approach as much because it is a LOT of boring boilerplate for the developer to add into her activity.  However, we could provide utilities to manage this and perhaps some tooling to create other services we may or may not need.

Summers


More information about the aerogear-dev mailing list