Skip to content Skip to sidebar Skip to footer

Get Application Instance From Static Method

Is it correct to use static method for getting instance of the Application successor in Android. I have seen this approach in a few open source projects: VLC and Shuttle public cla

Solution 1:

Yes. This approach is correct. This is singleton pattern you are following. As static variable is the right way always, since its the single state you want to maintain everywhere.

Also it is safe, as long as your application never runs in multiple processes. there's a strict one to one ratio of application per process.

I am also using this in my all applications.


Post a Comment for "Get Application Instance From Static Method"