Context

06 Feb 2023 . android .


Activity context

  • Attached to the lifecycle of an activity.
  • The activity context can be used when:
    • Passing the context in the scope of an activity.
    • Need the context whose lifecycle is attached to the context of the activity.

Application context:

  • Attached to the lifecycle of an application.
  • The application context should be used when:
    • Passing a context beyond the scope of activity.
    • Need a context whose lifecycle is separate from the current context.