-1

I have problem in understanding context class.
why does Toast.makeText need context class?

public static Toast makeText (Context context, CharSequence text, int duration)  
GrIsHu
  • 29,068
  • 10
  • 64
  • 102
user175023
  • 135
  • 7

2 Answers2

3

Feel free to examine the source to learn where the Context is used in Toast.

For example,

  • System resources
  • Your app's resources in case a string resource id is used.
  • Application package information
  • System services such as LayoutInflater and AccessibilityService
laalto
  • 150,114
  • 66
  • 286
  • 303
0

A context is the current state of the application/object. The toast function must have a context to know where it has to show the toast. Check out this post for more info on the context! What is 'Context' on Android?

Community
  • 1
  • 1
Chris
  • 3,329
  • 1
  • 30
  • 44