Skip to content Skip to sidebar Skip to footer

Managing A Connection To The Mysql Through A Service

I got a service that generate the phone location. I would like to send this string into my db but it's impossible through the service since I get a connection on main thread except

Solution 1:

That has nothing to do with the service itself.

The problem is that your operations are being executed on the UI thread, which is effectively stopping the UI from doing anything else.

The thread that calls the service life-cycle callbacks (onStartCommand(), onBind(), etc) is the UI thread. You just have to fire it on an executor service, or a new thread, or depending on what you're implementing a IntentService might be a handy class to use.


Post a Comment for "Managing A Connection To The Mysql Through A Service"