Is it possible to pause a background service currently running and running it again starting from the point its execution was stopped?
If not, is it at least possible to send a signal to stop the execution of SpiceService before it finishes its execution?
I am not a Robospice/Retrofit expert. But, this is a general question about http connection.
To achieve that you need to write a low level code to connect to the server. to open a stream to the service. this way you can check if the stream is still open. if yes add the new data to an array that your stream already takes data from to send to service.
Since you are using this library. This is not applicable. your only solution is to cancel/stop the connection and establish a new one.
This supposed to be easy:
if( spiceManager.isStarted() )
spiceManager.cancel(String.class, MY_REQUEST_CACHE_KEY);
And, then start a new one.
Note: There is a possibility that on checking if the spiceManager started to get a true. and before the cancelation the spiceManager connection finishes. In this case you should take in consideration to not submit the already submitted infos again. that would be a waste. It depend on your implementation. you may don't have to do extra work for this.
You can try use 'wait()' which is a Object's method .It can pause current thread until you used 'notify()' or 'notifyAll()' with the same Object in other thread .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With