I have a service which I call from my mainActivity.
here is the onStart method
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand service");
stopPolling = false;
startPolling();
return super.onStartCommand(intent, flags, startId);
}
now when I start this service from the main activity it runs this method. Now obviously if i am going to block in my startPolling()
method it will not return and my main activity will not respond.
How am I meant to start polling ? I am sure that i am missing some simple aspect of an android service which will allow for me to block.
EDIT: I was just reading on the android site and it appears that I have missed a vital sentence: "if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work".
I guess I am going to have to rethink my plan....