Question

According to RoboSpice documentation https://github.com/octo-online/robospice/wiki/Design-of-RoboSpice , i can use it in any Context.

Can't find an example of using Robospice in service context. I did some attempts but nothing happened, requests just not executes, no exceptions (Maybe some log leaking, what i need to do to enable robospice log on device?)

  1. Where to start/stop it? (spiceManager.start(this) / spiceManager.shouldStop())
  2. Where to create SpiceManager instance? (My service starts in application.onCreate() method, maybe i have to wait for some SpiceService initialization?)

some code

public abstract class SpicyService extends Service {

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

    @Override
    public void onCreate() {
        super.onCreate();
        spiceManager.start(this);
    }

    @Override
    public void onDestroy() {
        spiceManager.shouldStop();
        super.onDestroy();
    }
}
Était-ce utile?

La solution

Shame on me ...

After drinking some coffee i spotted that child Service, dont have super.onCreate() call to start spiceManager.

It's working perfectly fine now! Sorry for your time.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top