Someone explain humanly what Context in Android. I have experience of use, but I feel dissatisfaction, as its clear meaning eludes.

UPD. I would like to know, based on your practice, how it changes or does not change during the application, whether it changes from activity to activity, from activity to service ... or it is different for each component of the application, it has different capabilities in different situations. ..

2 answers 2

Context - an interface that provides global information about the application environment. It is an abstract class that is implemented using an Android system. Context allows you to access application resources and its classes, as well as make operation calls at the application level, for example: Launch Activity, Service, Broadcasting and Receiving intents, and so on.

Source Context

Diagram:


enter image description here

    Good question. Often it is asked at interviews for the position of Android developer. The most concise and correct answer to this question may sound something like this:

    Context is the interface for accessing Android operating system features.

    And, of course, this is not a secret, everything is available .

    • It is clear that I also have access. But I want somehow in Russian, in a friendly informal way - from experience. For example, does it change from activity to activity, from activity to service, during the operation of the application ... or is it different for each component of the application, has different capabilities in different situations ... - iramm
    • As I understand it, do you associate Context with the similarity of Handle (HWND, object identifier) ​​in Windows? At a lower level (where the C code) is. That is why each ui-entity has a context that is used more “low-level” when passing to the methods provided by the SDK. See how Context is interpreted in the native code. - AseN 8:40 pm