What is the difference between getContext(), getApplicationContext(), getBaseContext(), and this on Android?

Asked 2 years ago, Updated 2 years ago, 103 views

The difference between getContext(), getApplicationContext(), getBaseContext(), and this on Android is What is it?

android this android-context

2022-09-22 14:37

1 Answers

It returns the context of the currently running View, which is usually the context of the currently active activity.

The context of the application is returned. Currently, not only the context of the active but also the context corresponding to the lifeCycle of the application is used.

Use it to access contexts other than your own. The ContextWrapper may refer to the context through getBaseContext().

Same as View.getContext().


2022-09-22 14:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.