How to keep a Service with listeners alive after unbind in Android? -


i'm build chat app using xmpp. i've created service handle connection , incoming messages, adding different listeners needed.

the problem is, however, whenever activity calls unbind on service (e.g. when activity paused or stopped when user puts app in background) service gets destroyed, though has listeners inside (such chat listener, message listener, etc..)

how can keep service alive able receive messages when app in background? read using foreground service quite frowned upon, i'd rather avoid if possible.

i had when developing app recently.

the trick start service on own , bind using intent. when unbind it, service still continue running.

intent = new intent(this, dataservice.class); startservice(i);  bindservice(i, this, context.bind_auto_create); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -