"If you can't explain it to a six year old, you don't understand it yourself." — Albert Einstein
After reading about a context on the android developer web site and various other places on the web I am still a bit fuzzy. In this line of code I am a bit confused what the parameter really means. I am not ashamed to get a 6 year old answer....
TextView textView = new TextView(getBaseContext());
Thanks
A Context is a handle to the system; it provides services like resolving resources, obtaining access to databases and preferences, and so on. An Android app has activities. Context is like a handle to the environment your application is currently running in. The activity object inherits the Context object.
A Context provides access to information about the application state. It provides Activities, Fragments, and Services access to resource files, images, themes/styles, and external directory locations.
A context, is a way to describe the ether/environment an entity lives in and how to access other stuff living in this environment, interact with it.
:) First attempt of poetic answer for stack over flow ;)
At least, a 6 years old child would get the first four analogies.
More pragmatically, we can find different way to conceptualize what a context is, but it remains what the methods of this interface can offer as a set of services.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With