-1

In Android, what is context ( one of the parameter in toast)why we use this keyword as context? plz explain

i have tried on google but not getting answer.. i m using kotlin language in android.

  • Context is a class defined by the Android SDK. It isn't a keyword- it's a type. If you're seeing `somevas as Context` that's casting a variable into a Context. Which is something that would be very odd to do. – Gabe Sechan Nov 18 '22 at 07:24

1 Answers1

0

Refer to wiki , a context is the minimal set of data for a task to run.

In some programming architecture, a context always acts the role of an environment which linking up-stream and down-stream (or back-end and front-end).

In android, a Context is the interface to global information about an application environment.The global information includes resources and apis to get system services(getSystemService(..)). A context contains the necessay environment for an app to do something.

The android's contex may be an Activity, a Service, or an Application.

For a Toast, it needs a context to get text from Resources and get a system service (NotificationManager) to show the text.

greenfeel
  • 36
  • 1