I'm not sure if you can do that, but if your remote service, i.e. your 
server, needs authentication, consider using Http authentication. You'll 
send a token in the headers of your HTTP requests and handle non-authorized 
responses (HTTP Status=401) from your server appropriately. I.e. make your 
server's application stateless, where only a token can re-establish state 
in a manner that performs well on your server. This way, your client (your 
Android app) never has to worry about keeping a session alive. 

But maybe your server is and cannot be stateless:
Another way is to bind your foreground activities to a background service 
that communicates with your server. If no foreground activities are bound 
to your background service, Android will likely destroy your background 
service. When this happens, you can tell the server that your user left 
your app. You'll bind to the background service in your activities' 
onResume or onStart and unbind in their onPause or onStop. 

Note that the issues that Mark mentions still exist. Best to go stateless 
:-).



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to