How to declare global variables in Android?

前端 未结 17 3007
死守一世寂寞
死守一世寂寞 2020-11-21 04:12

I am creating an application which requires login. I created the main and the login activity.

In the main activity onCreate method I added the following

17条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 04:50

    The approach of subclassing has also been used by the BARACUS framework. From my point of view subclassing Application was intended to work with the lifecycles of Android; this is what any Application Container does. Instead of having globals then, I register beans to this context an let them beeing injected into any class manageable by the context. Every injected bean instance actually is a singleton.

    See this example for details

    Why do manual work if you can have so much more?

提交回复
热议问题