user2918962
user2918962

Reputation: 1

Where to call Robospice's shouldStop() method in Service class

I'm using Robospice library. It's really perfect library. But i don't understand something.

I want to perform request in Service class. Service has onStart method and i can call spiceManager.start(this) in onStart(). But Service hasn't got onStop. Where should i call spiceManager.shouldStop()?

public class SomeService extends Service {

    private SpiceManager spiceManager = new SpiceManager(
            JacksonSpringAndroidSpiceService.class);

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        spiceManager.start(getApplicationContext());
        performSomeRequest(getApplicationContext(), spiceManager,
                new SomeRequestListener());
    }
    ......
}

Upvotes: 0

Views: 199

Answers (1)

Deinlandel
Deinlandel

Reputation: 1033

Service.onDestroy() looks like the right place to do this.

Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up an resources it holds (threads, registered receivers, etc) at this point.

Upvotes: 2

Related Questions