问题
I use for javaEE project Spring, and I use bean injection with @Servive annotation. Now I'm going to make android's projects and I'd like to use the similar structure for my service bean. Is it a way to do it?
i.e.
public interface GlobalService {
final static String PACKAGE_ACTIVITY = "net.....activity.";
/**
* start an activity only by the activity name
* the intent is declared inside
* @param activityName
* @return True if the activity Start else False
*/
public boolean openActivity(String activityName);
}
then I have a class that implements interface
@Service("GlobalService")
public class GlobalServiceImpl implements GlobalService{
public boolean openActivity(String activityName) {
//some code ....
}
}
finally I declare into my class
@Autowired
private GlobalService globalService;
回答1:
Try to use AndroidAnnotations. It's not only IoC, but also great threading control tool and has many other features. It helps to write less code and does development more freindly.
来源:https://stackoverflow.com/questions/15426486/how-to-use-bean-into-android-project