Service Extras Builder
Roman Tcaregorodtcev edited this page Apr 2, 2018
·
1 revision
- @OmegaService - annotation for services.
- @OmegaExtraModel - annotation for classes, which will be putted to bundle.
- @OmegaExtra - annotation for fields, which will be putted to bundle.
@OmegaExtraModel and @OmegaExtra support prefix for generated method name.
If you wan't annotate your class with @OmegaExtra - this class should be implements Serializable
@OmegaService
public class TestService extends IntentService {
private static final String TAG = TestService.class.getSimpleName();
@OmegaExtra
String value;
@OmegaExtraModel(prefix = "model")
Model model = new Model();
public TestService() {
super(TAG);
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
AppOmegaIntentBuilder.inject(this, intent);
Log.d(TAG, value);
Log.d(TAG, model.getUrl());
}
}
Model class
public class Model implements Serializable {
@OmegaExtra("Var2")
String url;
public String getUrl() {
return url;
}
}
AppOmegaIntentBuilder.from(this)
.appServices()
.testService()
.value("Great library")
.modelVar2("Omega-R")
.startService();