in JQuery by
Q:
What is the difference between Activity and Context in Android?

▼ Show 1 Answer

0 votes
by

They are both instances of Context, but the application instance is tied to the lifecycle of the application, while the Activity instance is tied to the lifecycle of an Activity. Thus, they have access to different information about the application environment.

Get application context it notes that you should only use this if we need a context whose lifecycle is separate from the current context. This doesn't apply in either of your examples.

The Activity context presumably has some information about the current activity that is necessary to complete those calls. If we show the exact error message, might be able to point to what exactly it needs.

But in general, use the activity context unless you have a good reason not to.

Learn More with Madanswer

Related questions

0 votes
asked Jun 22, 2020 in JQuery by DavidAnderson
...