1. http://stackoverflow.com/questions/22966601/ what-is-different-between-mainactivity-this-vs-getapplicationcontext/22967165#22967165
There is types of the Context:
Application Context is associated with the application and would always being same throughout the life of application --it does not a change. If you are using a toast, you can use application context or even activity context (both) because Toast can displayed From anywhere with the your application and is not attached to a specific window. But there was many exceptions, one exception is, the activity context for you need to use or pass.
activity Context is associated with to the activity and can being destroyed if the activity is destroyed--there MA Y is multiple activities (more than likely) with a single application. And sometimes you absolutely need the activity context handle. For example, should-launch a new activity, you need-to-use activity context-its-Intent so, the new launching AC Tivity is connected to the current activity in terms of activity stack. However, application ' s context too to launch a new activity, and then you need to set flag intent.flag_activity _new_task in intent to treat it as a NEW TASK.
Let ' s consider some cases:
Mainactivity.this refers to the mainactivity context which extends activity class but the base class (activity) also exten DS Context class, so it can is used to the offer activity Context.
Getbasecontext () offers activity context.
Getapplication () offers application context.
Getapplicationcontext () also offers application context.
For more information please check the this link.
2. http://stackoverflow.com/questions/10641144/ difference-between-getcontext-getapplicationcontext-getbasecontext-and/10641257#10641257
View.getcontext (): Returns The context the View is currently running in. usually the currently active Activit Y.
Activity.getapplicationcontext (): Returns The context for the entire application (the process all the activities is running inside of). Use this instead of the current Activity context if you need a context tied to the lifecycle of the entire application, no t just the current Activity.
Contextwrapper.getbasecontext (): If You need access to a context from within another context, you use a CONTEXTWR Apper. The Context referred to from inside this contextwrapper is accessed via Getbasecontext ().
difference between GetContext (), Getapplicationcontext (), Getbasecontext ()