简体   繁体   中英

Can I use the Context object in Android like the Spring (or Eclipse RCP) context?

Suppose I have an Activity which has a couple other objects which are doing some work. Is there a convenient way to put shared objects into this Context object and use them elsewhere like I do when I use Eclipse RCP (e4)? Is this a good practice in Android terms?

I'm assuming that I do not switch activities, I'm just distributing work to other objects in my Activity .

I checked the API of Context but I did not find any obvious methods for this purpose.

Is there a convenient way to put shared objects into this Context object and use them elsewhere like I do when I use Eclipse RCP (e4)?

When you subclass Activity , you are welcome to have data members in it.

I'm assuming that I do not switch activities, I'm just distributing work to other objects in my Activity.

This sounds all the more like the role of standard data members and related methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM