I have a simple Java class like following, which doesn't extend from anything.
public class WeatherPresenter {
@App
CrossWeatherApplication application;
@Background
public void loadWeather(String city) {
}
}
So, up there, how can i use AndroidAnnotations like @App
and @Background
on that class ?
In AndroidAnnotations, all classes when you use annotations, have to be marked with the corresponding "enhanced component" annotation. In your example, you want to use @EBean
.
@EBean
public class WeatherPresenter {
@App
CrossWeatherApplication application;
@Background
public void loadWeather(String city) {
}
}
Then you can inject an instance of this bean into your Activity for example:
@EActivity
public class YourActivity extends Activity {
@Bean
WeatherPresenter weatherPresenter;
@AfterInject
void afterInject() {
weatherPresenter.loadWeather("New York");
}
}