-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No analog to the Service#onStartCommand() lifecycle method? #27
Comments
@curioustechizen, great catch. So, what do you say we remove the Service mapping of |
On second though, this may be a case for a call-through event method because of the return value out of onStartCommand(). |
I had forgotten about the return value of |
Ok, I'll add ServiceOnStartCommand shortly. YES, automatic binding (on injection?) would be awesome. It may be tricky to get right though, needs some thought. |
Just to clarify: The idiom for creating a started Service is as follows:
In other words, since I will think about bound services in greater detail and open a new feature request if I find it feasible. |
Yes, that is what the code generated by Transfuse would look like. @Service
@RegisterListener
public class Example implements ServiceOnStartCommand{
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return return android.app.Service.START_STICKY;
}
@OnDestroy
public void cleanup(){
//Do some cleanup
}
} triggers Transfuse to generate this: @Generated(value = "org.androidtransfuse.TransfuseAnnotationProcessor", date = "10/4/12 7:45 AM")
public class ExampleService extends Service implements ContextScopeHolder
{
private Example example_0;
private Scope scope_10 = new ConcurrentDoubleLockingScope();
public void onCreate() {
super.onCreate();
example_0 = new Example();
}
public void onDestroy() {
super.onDestroy();
example_0 .cleanup();
}
public IBinder onBind(Intent intent) {
return null;
}
public Scope getScope() {
return scope_10;
}
} |
Added additional missing Service lifecycle and call-through events
Food for thought, in the roboject project they bind Services through injection: https://github.com/akquinet/roboject/blob/master/roboject-tutorial/src/main/java/de/akquinet/android/roboject/tutorial/activities/RobojectAdderActivity.java |
Thanks for the clarification. |
Going through the documentation for
@Service
, I see that the following lifecycle events are defined for aService
@OnCreate
@OnStart
@OnDestroy
However,
onStart()
is deprecated and one should now useonStartCommand()
. I do not see any direct analog toonStartCommand()
in transfuse. Is this intended?The text was updated successfully, but these errors were encountered: