I just started playing with Roboguice, and I'm trying to put one of my services into action or fragment. It happens that my service is simply created and introduced as a POJO, and the life cycle methods are not called, which is why I suspect that I forgot to do something. However, I could only find examples of well-known services that were introduced.
The service looks something like this:
public class ProgramService extends RoboService { public ProgramService() { Log.i(getClass().getSimpleName(), "instantiating service " + hashCode()); } public class Binder extends android.os.Binder { public ProgramService getService() { return ProgramService.this; } } @Override public IBinder onBind(Intent arg0) { Log.i(getClass().getSimpleName(), "binding service " + hashCode()); return new Binder(); } @Override public void onCreate() { super.onCreate(); Log.i(getClass().getSimpleName(), "creating service " + hashCode()); } @Override public void onDestroy() { super.onDestroy(); Log.i(getClass().getSimpleName(), "destroying service " + hashCode()); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(getClass().getSimpleName(), "starting service " + hashCode()); return START_STICKY; }
}
And my activity looks something like this:
public class ProgramListActivity extends RoboFragmentActivity implements ProgramListFragment.Callbacks { private boolean mTwoPane; @Inject private ProgramService programService; ...
And the service is declared in the manifest as follows:
<service android:enabled="true" android:exported="false" android:name=".ProgramService"></service>
The only journal I get is the "instance service".
What do I need to do, Roboguice knows that the ProgramService is not a POJO, but a service? I have to miss something pretty simple.
Thank you in advance
source share